Skip to content

Commit 2c0d361

Browse files
committed
add postgres to django dockerfile for better backup system
1 parent 2b811b6 commit 2c0d361

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

compose/local/django/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ WORKDIR ${APP_HOME}
3838

3939
# Install required system dependencies
4040
RUN apt-get update && apt-get install --no-install-recommends -y \
41+
wget \
42+
gnupg \
4143
# psycopg2 dependencies
4244
libpq-dev \
4345
# Translations dependencies
4446
gettext \
4547
# pycurl dependencies
4648
libcurl4-openssl-dev \
4749
libssl-dev \
50+
# PostgreSQL 15
51+
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
52+
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
53+
&& apt-get update \
54+
&& apt-get install -y postgresql-15 postgresql-client-15 \
4855
# cleaning up unused files
4956
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
5057
&& rm -rf /var/lib/apt/lists/*

compose/production/django/Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ COPY ./requirements .
2323
RUN pip wheel --wheel-dir /usr/src/app/wheels \
2424
-r ${BUILD_ENVIRONMENT}.txt
2525

26-
2726
# Python 'run' stage
2827
FROM python AS python-run-stage
2928

@@ -39,16 +38,22 @@ WORKDIR ${APP_HOME}
3938
RUN addgroup --system django \
4039
&& adduser --system --ingroup django django
4140

42-
4341
# Install required system dependencies
4442
RUN apt-get update && apt-get install --no-install-recommends -y \
43+
wget \
44+
gnupg \
4545
# psycopg2 dependencies
4646
libpq-dev \
4747
# Translations dependencies
4848
gettext \
4949
# pycurl dependencies
5050
libcurl4-openssl-dev \
5151
libssl-dev \
52+
# PostgreSQL 15
53+
&& sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
54+
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
55+
&& apt-get update \
56+
&& apt-get install -y postgresql-15 postgresql-client-15 \
5257
# cleaning up unused files
5358
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
5459
&& rm -rf /var/lib/apt/lists/*
@@ -61,25 +66,22 @@ COPY --from=python-build-stage /usr/src/app/wheels /wheels/
6166
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
6267
&& rm -rf /wheels/
6368

64-
6569
COPY --chown=django:django ./compose/production/django/entrypoint /entrypoint
6670
RUN sed -i 's/\r$//g' /entrypoint
6771
RUN chmod +x /entrypoint
6872

69-
7073
COPY --chown=django:django ./compose/production/django/start /start
7174
RUN sed -i 's/\r$//g' /start
7275
RUN chmod +x /start
76+
7377
COPY --chown=django:django ./compose/production/django/celery/worker/start /start-celeryworker
7478
RUN sed -i 's/\r$//g' /start-celeryworker
7579
RUN chmod +x /start-celeryworker
7680

77-
7881
COPY --chown=django:django ./compose/production/django/celery/beat/start /start-celerybeat
7982
RUN sed -i 's/\r$//g' /start-celerybeat
8083
RUN chmod +x /start-celerybeat
8184

82-
8385
COPY ./compose/production/django/celery/flower/start /start-flower
8486
RUN sed -i 's/\r$//g' /start-flower
8587
RUN chmod +x /start-flower

0 commit comments

Comments
 (0)