Skip to content

Commit

Permalink
build improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
amancevice committed Dec 25, 2020
1 parent 6a9335d commit 20fff49
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 $^
Expand Down

0 comments on commit 20fff49

Please sign in to comment.