-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (32 loc) · 1.08 KB
/
Dockerfile
File metadata and controls
43 lines (32 loc) · 1.08 KB
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
# syntax=docker/dockerfile:1
ARG PYTHON_VERSION=3.10.12
FROM python:${PYTHON_VERSION}-slim as base
# Install system dependencies required by OpenCV and HEIF
RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0 libheif-dev && apt-get clean && rm -rf /var/lib/apt/lists/*
# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1
# Keeps Python from buffering stdout and stderr
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Create a non-privileged user that the app will run under.
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
# Copy requirements.txt and install dependencies.
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
# Copy the source code into the container.
COPY ./src ./src
# Copy Alembic config and migrations
COPY alembic.ini .
COPY ./migrations ./migrations
# Switch to the non-privileged user to run the application.
USER appuser
# Expose the port that the application listens on.
EXPOSE 8000