From 5d5c4838f188de5442397059fc0668e4dce926e1 Mon Sep 17 00:00:00 2001 From: Louis Mazin Date: Fri, 2 Oct 2026 16:09:10 +0200 Subject: [PATCH] test --- .env.example | 23 ------------- backend/Dockerfile | 22 +++++++++---- backend/entrypoint.sh | 6 ---- backend/requirements.txt | 1 + docker-compose.yml | 41 ++++++++++++++++------- dockerfile | 71 ++++++++++++++++++++++++++++++++++++++++ frontend/Dockerfile | 23 +++++++------ 7 files changed, 130 insertions(+), 57 deletions(-) delete mode 100644 .env.example delete mode 100644 backend/entrypoint.sh create mode 100644 dockerfile diff --git a/.env.example b/.env.example deleted file mode 100644 index 88d83b6..0000000 --- a/.env.example +++ /dev/null @@ -1,23 +0,0 @@ -# Database Configuration -MYSQL_HOST=172.18.0.1 -MYSQL_PORT=3306 -MYSQL_DATABASE=planning -MYSQL_USER=planning -MYSQL_PASSWORD=change-me -MYSQL_ROOT_PASSWORD=change-me - -# Django -SECRET_KEY=change-me -DEBUG=False -ADMIN_USERNAME=admin -ADMIN_PASSWORD=change-me -ADMIN_FIRST_NAME=Admin -ADMIN_LAST_NAME= -ALLOWED_HOSTS=localhost,127.0.0.1,192.168.1.19,planning.example.com -CSRF_TRUSTED_ORIGINS=http://localhost:1025,http://localhost:1031,http://192.168.1.19:1025,http://192.168.1.19:1031,https://planning.example.com -CORS_ALLOWED_ORIGINS=http://localhost:1025,http://192.168.1.19:1025,https://planning.example.com -PUBLIC_SITE_URL=https://planning.example.com - -# Notifications (optional) -NTFY_SERVER=https://ntfy.sh -NTFY_TOPIC= diff --git a/backend/Dockerfile b/backend/Dockerfile index 6c36368..bc2f01e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,9 +1,17 @@ -FROM python:3.12-slim -ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 +FROM python:3.11-slim + +RUN apt-get update && apt-get install -y \ + gcc \ + default-libmysqlclient-dev \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + WORKDIR /app -COPY requirements.txt . + +COPY requirements.txt /app/requirements.txt + RUN pip install --no-cache-dir -r requirements.txt -COPY . . -RUN chmod +x /app/entrypoint.sh -EXPOSE 8000 -ENTRYPOINT ["/app/entrypoint.sh"] + +COPY . /app/ + +CMD ["python", "manage.py", "runserver", "0.0.0.0:1031"] \ No newline at end of file diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh deleted file mode 100644 index 8442dc0..0000000 --- a/backend/entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -e -python manage.py wait_for_db -python manage.py migrate --noinput -python manage.py ensure_admin -exec gunicorn planning.wsgi:application --bind 0.0.0.0:8000 --workers 2 --threads 4 --timeout 60 --access-logfile - --error-logfile - diff --git a/backend/requirements.txt b/backend/requirements.txt index 9698387..182301b 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -5,3 +5,4 @@ django-cors-headers==4.9.0 gunicorn==23.0.0 PyMySQL==1.1.2 requests==2.32.5 +cryptography \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ba44f91..62859bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,38 @@ services: + db: + image: mysql:8.0 + restart: always + env_file: + - ".env" + ports: + - "3306:3306" + volumes: + - db_data:/var/lib/mysql + backend: build: ./backend - container_name: planning-backend - restart: unless-stopped - env_file: .env + volumes: + - ./backend:/app ports: - - "1031:8000" - extra_hosts: - - "host.docker.internal:host-gateway" - + - "1031:1031" + env_file: + - ".env" + environment: + MYSQL_HOST: db + depends_on: + - db frontend: build: ./frontend - container_name: planning-frontend - restart: unless-stopped + volumes: + - ./frontend:/app + - /app/node_modules + ports: + - "1025:1025" + env_file: + - ".env" depends_on: - backend - ports: - - "1025:80" + +volumes: + db_data: + diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..d3c1993 --- /dev/null +++ b/dockerfile @@ -0,0 +1,71 @@ +FROM node:20-bookworm + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + python3 \ + python3-pip \ + python3-venv \ + python3-dev \ + gcc \ + default-libmysqlclient-dev \ + pkg-config \ + git \ + curl \ + bash \ + && rm -rf /var/lib/apt/lists/* + +# Environnement Python +RUN python3 -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +# Utilisateur Pterodactyl +RUN useradd -m -d /home/container -s /bin/bash container \ + && mkdir -p /home/container \ + && chown -R container:container /home/container + +WORKDIR /home/container + +# ------------------------- +# Backend +# ------------------------- + +COPY backend/requirements.txt /tmp/requirements.txt + +RUN pip install --no-cache-dir \ + -r /tmp/requirements.txt + +# ------------------------- +# Frontend +# ------------------------- + +COPY frontend/package*.json /tmp/frontend/ + +WORKDIR /tmp/frontend + +RUN npm ci + +# ------------------------- +# Application +# ------------------------- + +WORKDIR /home/container + +COPY --chown=container:container backend /home/container/backend +COPY --chown=container:container frontend /home/container/frontend + +# On remet les node_modules installés +RUN rm -rf /home/container/frontend/node_modules \ + && cp -a /tmp/frontend/node_modules /home/container/frontend/node_modules \ + && chown -R container:container /home/container + +COPY --chown=container:container start.sh /home/container/start.sh + +RUN chmod +x /home/container/start.sh + +USER container + +ENV USER=container +ENV HOME=/home/container + +CMD ["/bin/bash", "/home/container/start.sh"] \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 458e1c1..f504d8a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,11 +1,14 @@ -FROM node:22-alpine AS build -WORKDIR /app -COPY package*.json ./ -RUN npm install -COPY . . -RUN npm run build +FROM node:20-alpine + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +EXPOSE 1025 + +CMD ["npm", "run", "dev", "--", "--host", "--port", "1025"] -FROM nginx:1.27-alpine -COPY nginx.conf /etc/nginx/conf.d/default.conf -COPY --from=build /app/dist /usr/share/nginx/html -EXPOSE 80