Skip to content

Commit edd9b82

Browse files
committed
Add Docker image
1 parent e7b9f95 commit edd9b82

File tree

6 files changed

+60
-7
lines changed

6 files changed

+60
-7
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!dist

.github/workflows/docker.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: docker
2+
on:
3+
push:
4+
jobs:
5+
docker:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
python:
10+
- 3.7
11+
- 3.8
12+
steps:
13+
- uses: actions/checkout@v1
14+
- uses: docker/login-action@v1
15+
with:
16+
username: ${{ secrets.DOCKERHUB_USERNAME }}
17+
password: ${{ secrets.DOCKERHUB_TOKEN }}
18+
- run: PYTHON_VERSION=${{ matrix.python }} docker-compose build
19+
- run: docker-compose push
20+
if: ${{ github.event_name == 'tag' }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,5 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
*.iid

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ARG PYTHON_VERSION=3.8
2+
FROM amazon/aws-lambda-python:${PYTHON_VERSION}
3+
ENV PYTHONPATH=/opt/python:/var/task
4+
EXPOSE 8000
5+
VOLUME /var/task
6+
VOLUME /opt/python
7+
COPY dist .
8+
RUN pip install *.tar.gz && rm *.tar.gz
9+
ENTRYPOINT [ "python", "-m", "lambda_gateway" ]

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1+
REPO := amancevice/lambda-gateway-python
12
SDIST := dist/$(shell python setup.py --fullname).tar.gz
23
SLEEP := 0
34
TIMEOUT := 3
45

56
.PHONY: all clean test up upload
67

7-
all: $(SDIST)
8+
all: Dockerfile.3.8.iid Dockerfile.3.7.iid
89

910
clean:
10-
rm -rf dist
11+
rm -rf dist *.iid coverage.xml
1112

1213
test: coverage.xml
1314

15+
up:
16+
SLEEP=$(SLEEP) python -m lambda_gateway -t $(TIMEOUT) lambda_function.lambda_handler
17+
1418
upload: $(SDIST)
1519
twine upload $<
1620

17-
up:
18-
SLEEP=$(SLEEP) python -m lambda_gateway -t $(TIMEOUT) lambda_function.lambda_handler
21+
Dockerfile.%.iid: $(SDIST) Dockerfile
22+
docker build \
23+
--build-arg PYTHON_VERSION=$* \
24+
--iidfile $@ \
25+
--tag $(REPO):$* \
26+
.
27+
28+
$(SDIST): coverage.xml
29+
python setup.py sdist
1930

2031
coverage.xml: $(shell find lambda_gateway tests -name '*.py')
2132
flake8 $^
2233
pytest
23-
24-
$(SDIST): coverage.xml
25-
python setup.py sdist

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '3.9'
2+
services:
3+
lambda_gateway:
4+
command: lambda_function.lambda_handler
5+
image: amancevice/lambda-gateway-python:${PYTHON_VERSION:-3.8}
6+
network_mode: bridge
7+
environment:
8+
SLEEP: ${SLEEP:-0}
9+
ports:
10+
- 8000
11+
volumes:
12+
- ./:/var/task

0 commit comments

Comments
 (0)