-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.template
35 lines (32 loc) · 1.41 KB
/
Dockerfile.template
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
FROM us-docker.pkg.dev/uwit-mci-iam/containers/base-python-3.9:latest AS dependencies
WORKDIR /app
COPY poetry.lock pyproject.toml ./
RUN --mount=type=secret,id=gcloud_auth_credentials \
md5sum /run/secrets/gcloud_auth_credentials
# get gcloud_auth_credentials secret from docker buildx (put in /run/secrets by default)
# install GAR keyring + setup ENV VAR per docs
# https://pypi.org/project/keyrings.google-artifactregistry-auth/
RUN --mount=type=secret,id=gcloud_auth_credentials \
poetry self add keyrings.google-artifactregistry-auth && \
export GOOGLE_APPLICATION_CREDENTIALS=/run/secrets/gcloud_auth_credentials && \
poetry install --only main --no-root --no-interaction
FROM dependencies AS app
# If you change your app directory to e.g., use src/ you MUST
# change the APP_MODULE here to match OR supply a --build-arg
ARG APP_MODULE=${template:app_name_underscore}
ARG FLASK_PORT=5000
ENV FLASK_ENV=development \
PYTHONPATH=${APP_MODULE} \
FLASK_APP=${APP_MODULE}.app
EXPOSE ${FLASK_PORT}
COPY ${APP_MODULE}/ ./${APP_MODULE}
# install root package now that we've copied it
# we depend on the metadata for the package to return the version
RUN poetry install --only-root
ENTRYPOINT ["poetry", "run", "flask", "run", "--host", "0.0.0.0"]
FROM app AS tests
WORKDIR tests/
COPY tests/ ./tests/
ENV PYTHONPATH="/app"
RUN poetry install --no-root --no-interaction # Install dev dependencies
ENTRYPOINT ["pytest"]