Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP- do not merge] Dockerfile and docker-compose stuff #7

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM osgeo/gdal:ubuntu-small-3.5.2
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.5.2

RUN apt-get update --fix-missing
RUN apt-get install gettext python3-pip libcairo2-dev build-essential python3-dev \
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
RUN pip3 install gunicorn
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/*

COPY ./requirements.txt /app/geoshop_back/requirements.txt
WORKDIR /app/geoshop_back/
RUN pip3 install -r requirements.txt
Expand All @@ -16,10 +18,5 @@ ENV PYTHONUNBUFFERED 1

COPY . /app/geoshop_back/

ARG ENV_FILE
RUN mv ${ENV_FILE} .env && mkdir /mnt/geoshop_data

RUN export $(egrep -v '^#' .env | xargs) && \
python manage.py migrate && \
python manage.py collectstatic --noinput && \
python manage.py compilemessages --locale=fr
# FIXME: why was this needed?
# RUN mkdir /mnt/geoshop_data
2 changes: 1 addition & 1 deletion api/management/commands/fixturize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Command(BaseCommand):
Creates internal group
"""
def handle(self, *args, **options):
admin_user = UserModel.objects.get(username='admin')
admin_user = UserModel.objects.get(username=os.environ.get('ADMIN_USERNAME', 'admin'))
admin_user.set_password(os.environ['ADMIN_PASSWORD'])
admin_user.save()

Expand Down
6 changes: 2 additions & 4 deletions default_settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import os
from dotenv import load_dotenv

load_dotenv()

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -232,7 +229,8 @@
INTRA_LEGEND_URL = os.environ.get('INTRA_LEGEND_URL', '')

# Geometries settings
DEFAULT_SRID = 2056
# FIXME: Does this work with another SRID?
DEFAULT_SRID = int(os.environ.get('DEFAULT_SRID', '2056'))

# Controls values of metadata accessibility field that will turn the metadata public
METADATA_PUBLIC_ACCESSIBILITIES = ['PUBLIC', 'APPROVAL_NEEDED']
56 changes: 56 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: '3'

networks:
geoshop:
driver: bridge

services:
db:
image: postgis/postgis:15-3.4-alpine
volumes:
- "./resources/db:/docker-entrypoint-initdb.d:ro"
environment:
LANG: 'en_US.utf8'
LC_COLLATE: 'en_US.utf8'
LC_CTYPE: 'en_US.utf8'
env_file: .env
ports:
- 5432:5432
networks:
- geoshop
healthcheck:
test: ["CMD-SHELL", "pg_isready -U geoshop"]
interval: 10s
timeout: 5s
retries: 5

migrate:
image: geoshop-api
build:
context: .
dockerfile: Dockerfile
depends_on:
db:
condition: service_healthy
env_file: .env
command:
- bash
- -c
- "python manage.py migrate && python manage.py collectstatic --noinput && python manage.py compilemessages --locale=fr && python manage.py fixturize"
networks:
- geoshop

api:
image: geoshop-api
depends_on:
db:
condition: service_healthy
migrate:
condition: service_completed_successfully
env_file: .env
command: "gunicorn wsgi -b :8000 --timeout 90"
restart: unless-stopped
ports:
- "8080:8000"
networks:
- geoshop
13 changes: 13 additions & 0 deletions resources/db/01_init_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS unaccent;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

CREATE SCHEMA IF NOT EXISTS geoshop AUTHORIZATION geoshop;


DROP TEXT SEARCH CONFIGURATION IF EXISTS fr;
CREATE TEXT SEARCH CONFIGURATION fr (COPY = simple);

ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING FOR hword, hword_part, word
WITH unaccent, simple;