generated from kamikaze/python3-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (37 loc) · 1.58 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
FROM python:3.11-slim as build-image
RUN apt-get update
RUN apt-get install -y curl ca-certificates gnupg
RUN curl -fSsL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/postgresql.gpg > /dev/null
RUN apt-get update
RUN apt-get install -y gcc g++ make postgresql-server-dev-all libpq-dev libffi-dev git cargo
COPY ./ /tmp/build
RUN (cd /tmp/build \
&& python3 -m venv venv-dev \
&& . venv-dev/bin/activate \
&& python3 -m pip install -U -r requirements_dev.txt \
&& python3 setup.py bdist_wheel)
WORKDIR /usr/local/app
COPY src/dataset_image_annotator/db/migrations ./migrations/
COPY src/dataset_image_annotator/db/alembic.ini ./alembic.ini
RUN (python3 -m venv venv \
&& . venv/bin/activate \
&& python3 -m pip install -U pip \
&& python3 -m pip install -U setuptools \
&& python3 -m pip install -U wheel \
&& python3 -m pip install -U uvloop \
&& python3 -m pip install -U /tmp/build/dist/*.whl)
FROM python:3.11-slim
ENV PYTHONPATH=/usr/local/app
COPY --from=build-image /usr/share/keyrings/ /usr/share/keyrings/
RUN mkdir -p /usr/local/app \
&& apt-get update \
&& apt-get install -y libpq-dev
WORKDIR /usr/local/app
COPY --from=build-image /usr/local/app/ ./
RUN groupadd -r appgroup \
&& useradd -r -G appgroup -d /home/appuser appuser \
&& install -d -o appuser -g appgroup /usr/local/app/logs
USER appuser
EXPOSE 8080
CMD ["/usr/local/app/venv/bin/python3", "-m", "uvicorn", "dataset_image_annotator.api.http:app", \
"--host", "0.0.0.0", "--port", "8080"]