-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
40 lines (30 loc) · 916 Bytes
/
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
# Use the official Python image for your desired Python version.
FROM python:3.9-slim as base
# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1
# Keeps Python from buffering stdout and stderr.
ENV PYTHONUNBUFFERED=1
# Install system dependencies, including SQLite.
RUN apt-get update && apt-get install -y sqlite3
WORKDIR /app
# Create a non-privileged user.
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
# Download dependencies.
COPY requirements.txt .
RUN pip install -r requirements.txt
# Copy the source code into the container.
COPY . .
# Switch to the non-privileged user.
USER appuser
# Copy the source code and the 'shared-db' directory into the container.
COPY --chown=appuser:appuser . .
# Run the Flask app.
CMD ["python3", "app.py"]