-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.jinja
58 lines (45 loc) · 1.5 KB
/
Dockerfile.jinja
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
54
55
56
57
58
FROM python:3.11.5-alpine
{% if from_ccsteam %}LABEL Maintainer="eXpress Unlimited Production"{% endif %}
# Install system-wide dependencies
RUN apk update && \
apk add --no-cache --clean-protected git curl gcc python3-dev && \
rm -rf /var/cache/apk/*
# Create user for app
ENV APP_USER=appuser
RUN adduser -D $APP_USER
WORKDIR /home/$APP_USER
USER $APP_USER
# Set python env vars
ENV PYTHONUNBUFFERED 1
ENV PYTHONNODEBUGRANGES 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONPATH="/home/$APP_USER:$PYTHONPATH"
# Use venv directly via PATH
ENV VENV_PATH=/home/$APP_USER/.venv/bin
ENV USER_PATH=/home/$APP_USER/.local/bin
ENV PATH="$VENV_PATH:$USER_PATH:$PATH"
# Set app env vars
ENV GUNICORN_CMD_ARGS ""
# Set build env vars
ARG CI_COMMIT_SHA=""
ENV GIT_COMMIT_SHA=${CI_COMMIT_SHA}
RUN pip install --user --no-cache-dir poetry==1.4.2 && \
poetry config virtualenvs.in-project true
COPY poetry.lock pyproject.toml ./
{% if has_private_dependencies == "yes" %}
ARG CI_JOB_TOKEN=""
ARG GIT_HOST=""
ARG GIT_PASSWORD=${CI_JOB_TOKEN}
ARG GIT_LOGIN="gitlab-ci-token"
# Poetry can't read password to download private repos
RUN echo -e "machine ${GIT_HOST}\nlogin ${GIT_LOGIN}\npassword ${GIT_PASSWORD}" > ~/.netrc && \
poetry install --only main && \
rm -rf ~/.netrc
{% else %}
RUN poetry install --only main
{% endif %}
COPY alembic.ini .
COPY app app
EXPOSE 8000
CMD alembic upgrade head && \
gunicorn "app.main:get_application()" --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0 $GUNICORN_CMD_ARGS