-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.template
36 lines (26 loc) · 1002 Bytes
/
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
36
FROM balenalib/%%BALENA_MACHINE_NAME%%-alpine-python:3.8-run
# Install poetry in the system python
RUN pip install --upgrade pip && pip install poetry
# Run everything from here as a non-privileged user
ENV USERNAME flask
RUN useradd -m $USERNAME
# If using an alpine image
# RUN addgroup -S $USERNAME && adduser -S $USERNAME -G $USERNAME
# Set a workdir
WORKDIR /home/$USERNAME/app
RUN chown $USERNAME.$USERNAME .
# Run as a non-privileged used
USER $USERNAME
# Copy the lock file. If it hasn't changed, we won't reinstall packages
COPY --chown=$USERNAME:$USERNAME poetry.lock pyproject.toml ./
# Install required packages, and the optional gunicorn
RUN poetry install --no-dev -E gunicorn
# Copy necessary files to container
COPY --chown=$USERNAME:$USERNAME src ./src
# Install this package as well
RUN poetry install --no-dev
# Expose port 5000
EXPOSE 5000
# Run gunicorn
ENTRYPOINT ["poetry", "run"]
CMD ["gunicorn", "-c", "src/gunicorn_config.py", "avgangstider.flask_app:create_app()"]