diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ecd035a..7ade66c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,10 +11,14 @@ jobs: - 3.8 steps: - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python }} - uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - run: PYTHON_VERSION=${{ matrix.python }} docker-compose build - - run: docker-compose push - if: ${{ github.event_name == 'tag' }} + - run: pip install . flake8 pytest pytest-cov + - run: make images + - run: make push + if: ${{ github.event_name == 'tags' }} diff --git a/Dockerfile b/Dockerfile index 6f8fc0b..6d71bd4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ ENV PYTHONPATH=/opt/python:/var/task EXPOSE 8000 VOLUME /var/task VOLUME /opt/python -COPY dist . -RUN pip install *.tar.gz && rm *.tar.gz +ARG TARBALL=lambda-gateway-latest.tar.gz +COPY ${TARBALL} ${TARBALL} +RUN pip install ${TARBALL} && rm ${TARBALL} ENTRYPOINT [ "python", "-m", "lambda_gateway" ] diff --git a/Makefile b/Makefile index 819dd27..04bf9b1 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,18 @@ SDIST := dist/$(shell python setup.py --fullname).tar.gz SLEEP := 0 TIMEOUT := 3 -.PHONY: all clean test up upload +.PHONY: all clean images push test up upload -all: Dockerfile.3.8.iid Dockerfile.3.7.iid +all: dist/lambda-gateway-latest.tar.gz clean: rm -rf dist *.iid coverage.xml +images: Dockerfile.3.7.iid Dockerfile.3.8.iid + +push: Dockerfile.3.7.iid Dockerfile.3.8.iid + docker push --all-tags $(REPO) + test: coverage.xml up: @@ -18,15 +23,19 @@ up: upload: $(SDIST) twine upload $< -Dockerfile.%.iid: $(SDIST) Dockerfile +Dockerfile.%.iid: dist/lambda-gateway-latest.tar.gz Dockerfile docker build \ --build-arg PYTHON_VERSION=$* \ + --build-arg TARBALL=$< \ --iidfile $@ \ --tag $(REPO):$* \ . -$(SDIST): coverage.xml - python setup.py sdist +dist/lambda-gateway-latest.tar.gz: $(SDIST) + cp $< $@ + +dist/lambda-gateway-%.tar.gz: coverage.xml + SETUPTOOLS_SCM_PRETEND_VERSION=$* python setup.py sdist coverage.xml: $(shell find lambda_gateway tests -name '*.py') flake8 $^