-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
44 lines (33 loc) · 1.24 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
FROM python:3.12-slim as base
ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
build-essential \
default-libmysqlclient-dev \
pkg-config
# Upgrade pip and add google packages
RUN pip3 install --upgrade pip setuptools
RUN pip3 install keyring keyrings.google-artifactregistry-auth
# Install requirements
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
RUN mkdir -p /opt/halodb-api
WORKDIR /opt/halodb-api
# Create a group and an user to avoid running the app as root
RUN addgroup --gid 1002 biocom
RUN adduser --disabled-password --gecos "" --force-badname --gid 1002 --uid 1021 halodb
# Switch to the new user
USER halodb
EXPOSE 5000
CMD exec gunicorn --reload \
--bind=:5000 --workers=1 --threads=2 --timeout=0 \
--access-logfile=- \
--error-logfile=- --log-level=DEBUG \
api.main:app
FROM base as production
COPY --chown=halodb:biocom api /opt/halodb-api/api
CMD exec gunicorn \
--bind=:5000 --workers=4 --threads=16 --timeout=0 \
--access-logfile=/var/log/halodb-api/access.log \
--error-logfile=/var/log/halodb-api/error.log --log-level=INFO \
api.main:app