Skip to content

Commit

Permalink
Update compose Dockerfiles (#645)
Browse files Browse the repository at this point in the history
* Update compose Dockerfiles

* Dockerfile refactoring (#646)

* Dockerfile refactoring

- Moves the dockerfile to root; enables accessing requirements etc from the dockerfile
- got rid of the Dockerfile-dev file because it wasn't being used anywhere. Would be better to add a docker-compose-dev file if we want.
- changed the base to official python image
- updated some dependencies

* switch to python 3.10

* run under a non-root user

* fix failing tests by downgrading psycopg2-binary

---------

Co-authored-by: Tarashish Mishra <[email protected]>
  • Loading branch information
willemarcel and sunu authored Oct 18, 2023
1 parent df36149 commit b45fc35
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 65 deletions.
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM python:3.10-slim-bookworm
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -qq -y \
&& apt-get install -y curl wget python3 python3-dev python3-pip git \
libgeos-dev libcurl4-gnutls-dev librtmp-dev python3-gdal libyaml-dev \
locales nginx supervisor postgresql-client libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Requirements have to be pulled and installed here, otherwise caching won't work
COPY ./requirements /requirements

RUN pip install -r /requirements/production.txt

COPY . /app
RUN useradd django
RUN chown -R django:django /app

COPY ./compose/django/gunicorn.sh /gunicorn.sh
COPY ./compose/django/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh \
&& sed -i 's/\r//' /gunicorn.sh \
&& chmod +x /entrypoint.sh \
&& chmod +x /gunicorn.sh

WORKDIR /app
USER django

ENTRYPOINT ["/entrypoint.sh"]
37 changes: 0 additions & 37 deletions compose/django/Dockerfile

This file was deleted.

19 changes: 0 additions & 19 deletions compose/django/Dockerfile-dev

This file was deleted.

6 changes: 0 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ services:
django:
build:
context: .
dockerfile: ./compose/django/Dockerfile
user: django
depends_on:
- postgres
- redis
Expand All @@ -38,8 +36,6 @@ services:
celeryworker:
build:
context: .
dockerfile: ./compose/django/Dockerfile
user: django
env_file: .env
depends_on:
- postgres
Expand All @@ -49,8 +45,6 @@ services:
celerybeat:
build:
context: .
dockerfile: ./compose/django/Dockerfile
user: django
env_file: .env
depends_on:
- postgres
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ django-cors-headers==3.7.0
drf-yasg==1.20.0

# For the persistence stores
psycopg2-binary<2.9
psycopg2-binary>=2.8,<2.9

# Unicode slugification
unicode-slugify==0.1.3
Expand Down
4 changes: 2 additions & 2 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# production that isn't in development.
-r base.txt

gevent==20.9.0
gunicorn==20.1.0
gevent==23.9.1
gunicorn==21.2.0

0 comments on commit b45fc35

Please sign in to comment.