2023-05-05 11:32:40 -04:00
|
|
|
FROM python:3.11.3-slim-buster AS base
|
2022-12-20 12:41:34 +01:00
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
|
python3-dev \
|
|
|
|
|
gcc \
|
|
|
|
|
libmariadb-dev \
|
2023-01-03 13:47:03 +01:00
|
|
|
libpq-dev \
|
2022-12-21 18:23:16 +01:00
|
|
|
netcat \
|
|
|
|
|
curl \
|
2023-05-05 11:32:40 -04:00
|
|
|
bash \
|
2023-06-05 16:43:10 +08:00
|
|
|
git \
|
|
|
|
|
libpcre3 \
|
|
|
|
|
libpcre3-dev
|
2022-06-03 08:09:47 -06:00
|
|
|
|
|
|
|
|
WORKDIR /etc/app
|
|
|
|
|
COPY ./requirements.txt ./
|
2022-12-20 12:41:34 +01:00
|
|
|
RUN pip install --upgrade pip
|
2022-06-03 08:09:47 -06:00
|
|
|
RUN pip install -r requirements.txt
|
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
# we intentionally have two COPY commands, this is to have the requirements.txt in a separate build step
|
|
|
|
|
# which only invalidates when the requirements.txt actually changes. This avoids having to unneccasrily reinstall deps (which is time-consuming)
|
|
|
|
|
# https://stackoverflow.com/questions/34398632/docker-how-to-run-pip-requirements-txt-only-if-there-was-a-change/34399661#34399661
|
2022-06-03 08:09:47 -06:00
|
|
|
COPY ./ ./
|
|
|
|
|
|
2023-05-22 20:16:31 +01:00
|
|
|
# Collect static files
|
2023-01-21 21:59:20 +08:00
|
|
|
RUN DJANGO_SETTINGS_MODULE=settings.prod_without_db DATABASE_TYPE=sqlite3 DATABASE_NAME=/var/lib/oncall/oncall.db SECRET_KEY="ThEmUsTSecretKEYforBUILDstage123" SILK_PROFILER_ENABLED="True" python manage.py collectstatic --no-input
|
2023-05-22 20:16:31 +01:00
|
|
|
|
|
|
|
|
# Create SQLite database and set permissions
|
|
|
|
|
RUN mkdir -p /var/lib/oncall
|
|
|
|
|
RUN DATABASE_TYPE=sqlite3 DATABASE_NAME=/var/lib/oncall/oncall.db python manage.py create_sqlite_db
|
2022-10-04 09:25:53 +01:00
|
|
|
RUN chown -R 1000:2000 /var/lib/oncall
|
|
|
|
|
|
2023-01-26 20:33:04 +08:00
|
|
|
# This is required for silk profilers to sync between uwsgi workers
|
|
|
|
|
RUN mkdir -p /tmp/silk_profiles;
|
|
|
|
|
RUN chown -R 1000:2000 /tmp/silk_profiles
|
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
FROM base AS dev
|
2022-12-20 12:41:34 +01:00
|
|
|
RUN apt-get install -y sqlite3 default-mysql-client postgresql-client
|
2022-11-07 16:34:43 +01:00
|
|
|
|
2022-11-09 07:21:33 +01:00
|
|
|
FROM dev AS dev-enterprise
|
2022-11-10 16:04:30 +01:00
|
|
|
RUN pip install -r requirements-enterprise-docker.txt
|
2022-11-09 07:21:33 +01:00
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
FROM base AS prod
|
2022-06-03 08:09:47 -06:00
|
|
|
|
|
|
|
|
# This is required for prometheus_client to sync between uwsgi workers
|
|
|
|
|
RUN mkdir -p /tmp/prometheus_django_metrics;
|
|
|
|
|
RUN chown -R 1000:2000 /tmp/prometheus_django_metrics
|
|
|
|
|
ENV prometheus_multiproc_dir "/tmp/prometheus_django_metrics"
|
|
|
|
|
|
|
|
|
|
CMD [ "uwsgi", "--ini", "uwsgi.ini" ]
|