Skip to content

Commit

Permalink
Merge pull request #25 from camptocamp/GSGGR-150-geoshop-poetry
Browse files Browse the repository at this point in the history
GSGGR-150 Migrate geoshop from pip requirements to poetry
  • Loading branch information
lanseg authored Aug 15, 2024
2 parents 6d158b9 + e54b48b commit d38750a
Show file tree
Hide file tree
Showing 8 changed files with 685 additions and 75 deletions.
27 changes: 13 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.5.2
FROM python:3.12.5-slim-bookworm
LABEL Maintainer="andrey.rusakov@camptocamp.com" Vendor="Camptocamp"

RUN apt-get update --fix-missing && \
apt-get install gettext python3-pip libcairo2-dev build-essential python3-dev \
pipenv python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 \
libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info libpq-dev -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
POETRY_HOME='/usr/local'

COPY ./requirements.txt /app/geoshop_back/requirements.txt
WORKDIR /app/geoshop_back/
RUN pip3 install -r requirements.txt
COPY poetry.lock pyproject.toml /app/geoshop_back/

# Update C env vars so compiler can find gdal
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal
ENV PYTHONUNBUFFERED 1
RUN apt update && apt install -y libgdal-dev libffi-dev && \
pip install poetry && \
poetry install --only=main

COPY . /app/geoshop_back/
RUN mv /app/geoshop_back/default_settings.py /app/geoshop_back/settings.py

# Copy default settings to settings only if there is no such file
RUN mv -vn /app/geoshop_back/default_settings.py /app/geoshop_back/settings.py
2 changes: 1 addition & 1 deletion api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

UserModel = get_user_model()

class CustomModelAdmin(admin.GeoModelAdmin):
class CustomModelAdmin(admin.GISModelAdmin):
"""
This is just a cosmetic class adding custom CSS and Replacing CharField Widget by
a TextField widget when Charfields are longer than 300 characters.
Expand Down
2 changes: 1 addition & 1 deletion api/templates/rest_framework/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a rel="nofollow" href="{% url 'admin:index' %}">Admin</a>
</li>
{% if user.is_authenticated %}
{% optional_logout request user %}
{% optional_logout request user csrf_token %}
{% else %}
{% optional_login request %}
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'allauth.account.middleware.AccountMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down
13 changes: 7 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ services:
env_file: .env
environment:
PGHOST: "db"
command:
- bash
- -c
- "python manage.py migrate && python manage.py collectstatic --noinput && python manage.py compilemessages --locale=fr && python manage.py fixturize"
command: >
python3 manage.py migrate &&
python3 manage.py collectstatic --noinput &&
python3 manage.py compilemessages --locale=fr &&
python3 manage.py fixturize
volumes:
- "static-files:/app/geoshop_back/static:rw"
networks:
Expand All @@ -58,12 +59,12 @@ services:
env_file: .env
environment:
PGHOST: "db"
command: "gunicorn wsgi -b :8000 --timeout 90"
command: gunicorn wsgi -b :8000 --timeout 90
restart: unless-stopped
volumes:
- "static-files:/app/geoshop_back/static:ro"
ports:
- "8080:8000"
- "8000:8000"
networks:
- geoshop

Expand Down
Loading

0 comments on commit d38750a

Please # to comment.