Skip to content

Commit

Permalink
Merge pull request #25 from ricardogsilva/24-use-poetry
Browse files Browse the repository at this point in the history
Use poetry as package manager
  • Loading branch information
francbartoli authored Feb 22, 2024
2 parents c0a9f68 + bd40ff2 commit 4b8f3f3
Show file tree
Hide file tree
Showing 12 changed files with 2,305 additions and 413 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.venv

tileserver
80 changes: 0 additions & 80 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion backend/djangoapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
]

WSGI_APPLICATION = os.environ.get('WSGI_APPLICATION', 'djangoapp.wsgi.application')
ASGI_APPLICATION = os.environ.get('ASGI_APPLICATION', 'djangoapp.asgi.channel_layer')
ASGI_APPLICATION = os.environ.get('ASGI_APPLICATION', 'djangoapp.asgi.app')

# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
Expand Down
28 changes: 0 additions & 28 deletions check_db.py

This file was deleted.

40 changes: 15 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,19 @@ services:
backend:
env_file: .env
container_name: backend.api
image: padoa_backend
build: .
command: ${API_COMMAND:-dev}
image: "ghcr.io/geobeyond/arpav_ppcv_backend:${CURRENT_GIT_BRANCH:-latest}"
restart: unless-stopped
# user: ${UID:-1000}
environment:
GUNICORN_WORKERS: 15
GUNICORN_WORKER_TIMEOUT: 120
expose:
- 8000
# ports:
# - 8000:8000
depends_on:
- postgis
# - proxy
volumes:
- ./backend/djangoapp:/opt/api/app/djangoapp
- ./backend/padoa:/opt/api/app/padoa
- ./backend/storage:/opt/api/app/storage
- ./backend/resources:/opt/api/app/resources
- ./backend/templates:/opt/api/app/templates
- ./docker/backend/docker-entrypoint.sh:/opt/api/docker-entrypoint.sh
- .env:/opt/api/app/.env
- type: bind
source: $PWD
target: /home/appuser/app

martin:
image: 'maplibre/martin:v0.6'
Expand Down Expand Up @@ -76,11 +66,11 @@ services:
- 80
- 443
ports:
- 80:80
- 443:443
- 8000:80
- 4430:443
environment:
- NGINX_HOST=proxy
- NGINX_PORT=80
- NGINX_PORT=8000
depends_on:
- backend
- thredds
Expand All @@ -98,14 +88,14 @@ services:
environment:
- THREDDS_PASSWORD=${THREDDS_PASSWORD}

frontend:
container_name: frontend
image: ppcv_frontend:latest
build:
context: ./Arpav-PPCV
expose:
- 80
restart: always
# frontend:
# container_name: frontend
# image: ppcv_frontend:latest
# build:
# context: ./Arpav-PPCV
# expose:
# - 80
# restart: always

volumes:
redisdata:
Expand Down
59 changes: 59 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM python:3.10

# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
gdal-bin \
apt-utils \
libgdal-dev \
tini

# download poetry
RUN curl --silent --show-error --location \
https://install.python-poetry.org > /opt/install-poetry.py

# Create a normal non-root user so that we can use it to run
RUN useradd --create-home appuser

# Compile python stuff to bytecode to improve startup times
RUN python -c "import compileall; compileall.compile_path(maxlevels=10)"

USER appuser

# create relevant directories and install poetry
RUN mkdir /home/appuser/app && \
mkdir /home/appuser/data && \
python opt/install-poetry.py --yes --version 1.7.1

ENV PATH="$PATH:/home/appuser/.local/bin" \
PYTHONUNBUFFERED=1 \
# This allows us to get traces whenever some C code segfaults
PYTHONFAULTHANDLER=1

WORKDIR /home/appuser/app

COPY --chown=appuser:appuser pyproject.toml poetry.lock ./

RUN poetry install --no-root --only main

EXPOSE 8000

ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT \
DJANGO_SETTINGS_MODULE=djangoapp.settings

# Now install our code
COPY --chown=appuser:appuser . .
RUN poetry install --only main

# Write git commit identifier into the image
RUN echo $GIT_COMMIT > /home/appuser/git-commit.txt

# Compile python stuff to bytecode to improve startup times
RUN poetry run python -c "import compileall; compileall.compile_path(maxlevels=10)"

# use tini as the init process
ENTRYPOINT ["tini", "-g", "--", "poetry", "run", "django-admin"]

CMD ["runserver", "0.0.0.0:8000"]
Loading

0 comments on commit 4b8f3f3

Please sign in to comment.