mirror of https://gitlab.federez.net/re2o/re2o
15 changed files with 189 additions and 16 deletions
@ -0,0 +1,36 @@ |
|||||
|
version: "3" |
||||
|
|
||||
|
volumes: |
||||
|
database_data: |
||||
|
driver: local |
||||
|
|
||||
|
services: |
||||
|
db: |
||||
|
image: postgres:latest |
||||
|
volumes: |
||||
|
- database_data:/var/lib/postgresql/data |
||||
|
environment: |
||||
|
- POSTGRES_DB=postgres |
||||
|
- POSTGRES_USER=postgres |
||||
|
- POSTGRES_PASSWORD=postgres |
||||
|
|
||||
|
re2o: |
||||
|
build: |
||||
|
context: . |
||||
|
dockerfile: ./docker/Dockerfile-re2o |
||||
|
target: postgres-dev |
||||
|
depends_on: |
||||
|
- db |
||||
|
ports: |
||||
|
- "8000:8000" |
||||
|
volumes: |
||||
|
- .:/code |
||||
|
environment: |
||||
|
- POSTGRES_DB=postgres |
||||
|
- POSTGRES_USER=postgres |
||||
|
- POSTGRES_PASSWORD=postgres |
||||
|
- SUPERUSER_LOGIN=admin |
||||
|
- SUPERUSER_PASS=admin |
||||
|
- SUPERUSER_EMAIL=admin@example.net |
||||
|
- ENV=dev |
||||
|
entrypoint: ./docker/docker-entrypoint-dev.sh |
||||
@ -0,0 +1,13 @@ |
|||||
|
FROM python:3.9-bullseye AS build |
||||
|
ENV PYTHONUNBUFFERED=1 |
||||
|
RUN pip install poetry |
||||
|
WORKDIR /code |
||||
|
RUN apt-get update && apt-get install -y --no-install-recommends gettext-base gettext libpq-dev |
||||
|
COPY . /code/ |
||||
|
RUN poetry install --extras "postgresql" |
||||
|
RUN ENV=dev DATABASE_URL='' poetry run python manage.py collectstatic --noinput |
||||
|
RUN poetry run python manage.py compilemessages |
||||
|
|
||||
|
FROM nginx |
||||
|
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf |
||||
|
COPY --from=build /code/static_files /static |
||||
@ -0,0 +1,29 @@ |
|||||
|
#!/usr/bin/env bash |
||||
|
set -euo pipefail |
||||
|
|
||||
|
cp -n cotisations/templates/cotisations/invoice.html templates/default_invoice.html |
||||
|
cp -n cotisations/templates/cotisations/voucher.html templates/default_voucher.html |
||||
|
|
||||
|
AUTOMIGRATE=${AUTOMIGRATE:-yes} |
||||
|
|
||||
|
if [ "$AUTOMIGRATE" != "skip" ]; then |
||||
|
poetry run python manage.py migrate --noinput |
||||
|
fi |
||||
|
|
||||
|
poetry run python manage.py collectstatic -c --noinput |
||||
|
poetry run python manage.py compilemessages |
||||
|
|
||||
|
cat <<EOF | poetry run python manage.py shell |
||||
|
from django.contrib.auth import get_user_model |
||||
|
|
||||
|
User = get_user_model() |
||||
|
|
||||
|
User.objects.filter(pseudo='$SUPERUSER_LOGIN').exists() or \ |
||||
|
User.objects.create_superuser(pseudo='$SUPERUSER_LOGIN', email='$SUPERUSER_EMAIL', password='$SUPERUSER_PASS', surname='$SUPERUSER_LOGIN') |
||||
|
EOF |
||||
|
|
||||
|
if [ "$RUN_TESTS" != "no" ]; then |
||||
|
poetry run python manage.py test |
||||
|
else |
||||
|
poetry run python manage.py runserver 0.0.0.0:8000 |
||||
|
fi |
||||
@ -0,0 +1,30 @@ |
|||||
|
server { |
||||
|
listen 80; |
||||
|
client_max_body_size 4G; |
||||
|
|
||||
|
server_name localhost; |
||||
|
|
||||
|
keepalive_timeout 5; |
||||
|
|
||||
|
|
||||
|
location /static { |
||||
|
alias /static; |
||||
|
} |
||||
|
|
||||
|
location /media/ { |
||||
|
alias /media; |
||||
|
} |
||||
|
|
||||
|
location / { |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
proxy_set_header X-Forwarded-Proto $scheme; |
||||
|
proxy_set_header Host $http_host; |
||||
|
proxy_redirect off; |
||||
|
proxy_pass http://re2o:8000; |
||||
|
} |
||||
|
|
||||
|
error_page 500 502 503 504 /50x.html; |
||||
|
location = /50x.html { |
||||
|
root /usr/share/nginx/html; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue