Skip to content

Commit

Permalink
feat: use poetry and update compose.yaml production
Browse files Browse the repository at this point in the history
  • Loading branch information
Maël Marchand committed Dec 27, 2023
1 parent 9ea4b6d commit 2ce36b0
Show file tree
Hide file tree
Showing 10 changed files with 1,176 additions and 252 deletions.
8 changes: 0 additions & 8 deletions .githooks/post-receive

This file was deleted.

5 changes: 0 additions & 5 deletions .githooks/pre-commit

This file was deleted.

29 changes: 24 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
FROM python:3.9.4-buster
FROM python:3.11.5-alpine3.18

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

RUN apk update && apk add --no-cache tzdata
ENV TZ=Europe/Paris

WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip -q install -r requirements.txt
RUN apt-get -qq update && apt-get -yqq install default-jre
COPY pyproject.toml poetry.lock ./
RUN pip install poetry==1.6.1 \
&& poetry config virtualenvs.create false \
&& apk add --no-cache libpq-dev \
&& apk add --no-cache --virtual .build-deps \
build-base \
&& poetry install --no-interaction --no-ansi \
&& apk add --no-cache \
openjdk17 \
&& apk del .build-deps

COPY . ./

RUN python manage.py collectstatic --noinput

EXPOSE 80
CMD ["daphne", "project.asgi:application", "-b", "0.0.0.0", "-p", "80"]
69 changes: 0 additions & 69 deletions deploy/apache-example.conf

This file was deleted.

69 changes: 51 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,65 @@
version: "3.9"

services:
postgres:
container_name: mc_manager_db
image: postgres
volumes:
- ./vardb:/var/lib/postgresql/data
- database:/var/lib/postgresql/data
networks:
- default
environment:
- POSTGRES_DB=mcmanager
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
daphne:
build: .
command: >
bash -c "python manage.py migrate --noinput &&
python manage.py collectstatic --noinput &&
daphne project.asgi:application -b 0.0.0.0 -p 8000"
restart: always

django: &django
container_name: mc_manager
build:
context: .
dockerfile: Dockerfile
deploy:
restart_policy:
condition: any
resources:
limits:
cpus: "2"
memory: 6G
reservations:
cpus: ".1"
memory: 256M
depends_on:
- postgres
networks:
- default
- traefik
volumes:
- .:/app:delegated
- data:/data
ports:
- "8000:8000"
- "25565-25600:25565-25600"
depends_on:
- postgres
labels:
traefik.enable: true
traefik.docker.network: traefik
traefik.http.routers.mc_manager.rule: Host(`minecraft.marchand.cloud`)
traefik.http.routers.mc_manager.entrypoints: https
traefik.http.routers.mc_manager.tls: true
traefik.http.routers.mc_manager.tls.certresolver: letsencrypt

django_migration:
<<: *django
container_name: mc_manager_migration
deploy: {}
command: python manage.py migrate
volumes: []
ports: []
labels: {}

networks:
default:
traefik:
external: true
name: traefik

volumes:
var:
driver: local
vardb:
driver: local

data:
database:
Empty file modified manage.py
100644 → 100755
Empty file.
Loading

0 comments on commit 2ce36b0

Please sign in to comment.