-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
53 lines (37 loc) · 1.16 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM python:3.8 AS base
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
ENV PIP_DEFAULT_TIMEOUT=100
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_CACHE_DIR=1
ENV POETRY_VERSION=1.3.2
RUN pip install "poetry==$POETRY_VERSION"
COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.in-project true
RUN poetry install --no-interaction --no-root
FROM base as build
COPY . .
RUN poetry build
FROM base AS execute
ENV PATH=/app/.venv/bin:$PATH
COPY --from=build /app/dist .
COPY --from=build /app/.venv ./.venv
RUN ./.venv/bin/pip install *.whl
COPY ./config ./config
ENTRYPOINT ["python", "-m", "notifier"]
FROM base AS test
ENV PATH=/app/.venv/bin:$PATH
RUN apt-get update && apt-get install -y default-mysql-client
COPY conftest.py .
COPY config/ config/
COPY tests/ tests/
COPY notifier/ notifier/
ENTRYPOINT ["pytest", "-vvx"]
FROM amazon/aws-lambda-python:3.8 AS execute_lambda
COPY --from=build /app/dist ${LAMBDA_TASK_ROOT}
RUN pip install ${LAMBDA_TASK_ROOT}/*.whl
COPY ./config ${LAMBDA_TASK_ROOT}/config
ENV PATH=${LAMBDA_TASK_ROOT}/.venv/bin:$PATH
COPY ./lambda_function.py ${LAMBDA_TASK_ROOT}
CMD ["lambda_function.lambda_handler"]