Skip to content

Commit

Permalink
Merge pull request #220 from SELab-2/poetry
Browse files Browse the repository at this point in the history
feat(deplyment): added poetry
  • Loading branch information
EwoutV authored Apr 3, 2024
2 parents 856e744 + 8caad92 commit 4a83e9b
Show file tree
Hide file tree
Showing 13 changed files with 1,497 additions and 159 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/backend-linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r ./backend/requirements.txt
pip install poetry
poetry install --directory=./backend
- name: Execute linting checks
run: flake8 --config ./backend/.flake8 ./backend
4 changes: 2 additions & 2 deletions .github/workflows/backend-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r ./backend/requirements.txt
pip install poetry
poetry install --directory=./backend
- name: Compile translations
run: django-admin compilemessages
- name: Execute tests
Expand Down
12 changes: 6 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM python:3.11.4

RUN apt update && apt install -y gettext libgettextpo-dev && pip install --upgrade pip
RUN apt update && apt install -y gettext libgettextpo-dev && pip install --upgrade pip && pip install -U poetry
RUN poetry config virtualenvs.create false

WORKDIR /code

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY pyproject.toml poetry.lock ./
RUN poetry install --only main

COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . .

COPY . /code/
RUN ./setup.sh
16 changes: 0 additions & 16 deletions backend/Dockerfile.dev

This file was deleted.

15 changes: 0 additions & 15 deletions backend/Dockerfile.prod

This file was deleted.

14 changes: 4 additions & 10 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
# Prerequisites
# Prerequisites

- python 3.11.8
- python 3.11.8

__Django doesn't support python 3.12__
**Django doesn't support python 3.12**

# Install instructions

- Create a virtual environment `python -m venv .venv` (make sure to use the right python version)

- Activate the virtual environment `source .venv/bin/activate`

- Run `setup.sh`

- Run the server `python manage.py runsslserver localhost:8080`
- See [wiki](https://github.com/SELab-2/UGent-7/wiki/Setup-and-deployment#development)
1,358 changes: 1,358 additions & 0 deletions backend/poetry.lock

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "backend"
version = "0.1.0"
description = ""
authors = ["Topvennie <[email protected]>"]
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = "^3.11.4"
django = "^5.0.3"
django-sslserver = "^0.22"
djangorestframework = "^3.15.1"
django-rest-swagger = "^2.2.0"
drf-yasg = "^1.21.7"
requests = "^2.31.0"
cas-client = "^1.0.0"
psycopg2-binary = "^2.9.9"
djangorestframework-simplejwt = "^5.3.1"
celery = {extras = ["redis"], version = "^5.3.6"}
django-redis = "^5.4.0"
gunicorn = "^21.2.0"
whitenoise = "^6.6.0"
flake8 = "^7.0.0"
celery-types = "^0.22.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
13 changes: 0 additions & 13 deletions backend/requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions backend/ypovoli/celery.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os

from celery import Celery
from celery.app.task import Task

Task.__class_getitem__ = classmethod(lambda cls, *args, **kwargs: cls) # type: ignore[attr-defined]

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ypovoli.settings")
Expand Down
4 changes: 1 addition & 3 deletions development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ x-common-keys-selab: &common-keys-selab
############################# SERVICES

services:

nginx:
<<: *common-keys-selab
image: nginx:latest
Expand All @@ -49,7 +48,7 @@ services:
container_name: backend
build:
context: $BACKEND_DIR
dockerfile: Dockerfile.dev
dockerfile: Dockerfile
command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
expose:
- 8080
Expand Down Expand Up @@ -95,4 +94,3 @@ services:
entrypoint: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
volumes:
- ${DATA_DIR}/redis:/data

5 changes: 2 additions & 3 deletions production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ x-common-keys-selab: &common-keys-selab
############################# SERVICES

services:

nginx:
<<: *common-keys-selab
image: nginx:latest
Expand Down Expand Up @@ -64,7 +63,7 @@ services:
container_name: backend
build:
context: $BACKEND_DIR
dockerfile: Dockerfile.prod
dockerfile: Dockerfile
command: bash -c "./setup.sh && gunicorn --config gunicorn_config.py ypovoli.wsgi:application"
expose:
- 8080
Expand Down Expand Up @@ -106,4 +105,4 @@ services:
expose:
- 3000
depends_on:
- backend
- backend
178 changes: 89 additions & 89 deletions test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,105 +3,105 @@ version: "3.9"
############################# NETWORKS

networks:
selab_network:
name: selab_network
driver: bridge
ipam:
config:
- subnet: 192.168.90.0/24
selab_network:
name: selab_network
driver: bridge
ipam:
config:
- subnet: 192.168.90.0/24

############################# EXTENSIONS

x-common-keys-selab: &common-keys-selab
networks:
- selab_network
security_opt:
- no-new-privileges:true
restart: unless-stopped
environment:
TZ: $TZ
PUID: $PUID
PGID: $PGID
env_file:
- .env
networks:
- selab_network
security_opt:
- no-new-privileges:true
restart: unless-stopped
environment:
TZ: $TZ
PUID: $PUID
PGID: $PGID
env_file:
- .env

############################# SERVICES

services:
nginx:
<<: *common-keys-selab
image: nginx:latest
container_name: nginx
expose:
- 80
- 443
- 8080
volumes:
- ${DATA_DIR}/nginx/nginx.dev.conf:/etc/nginx/nginx.conf:ro
- ${SSL_DIR}:/etc/nginx/ssl:ro
depends_on:
- backend
- frontend
nginx:
<<: *common-keys-selab
image: nginx:latest
container_name: nginx
expose:
- 80
- 443
- 8080
volumes:
- ${DATA_DIR}/nginx/nginx.dev.conf:/etc/nginx/nginx.conf:ro
- ${SSL_DIR}:/etc/nginx/ssl:ro
depends_on:
- backend
- frontend

backend:
<<: *common-keys-selab
container_name: backend
build:
context: $BACKEND_DIR
dockerfile: Dockerfile.dev
command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
expose:
- 8080
volumes:
- $BACKEND_DIR:/code
backend:
<<: *common-keys-selab
container_name: backend
build:
context: $BACKEND_DIR
dockerfile: Dockerfile
command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
expose:
- 8080
volumes:
- $BACKEND_DIR:/code

celery:
<<: *common-keys-selab
container_name: celery
build:
context: $BACKEND_DIR
dockerfile: Dockerfile.dev
command: celery -A ypovoli worker -l DEBUG
volumes:
- $BACKEND_DIR:/code
depends_on:
- backend
- redis
celery:
<<: *common-keys-selab
container_name: celery
build:
context: $BACKEND_DIR
dockerfile: Dockerfile.dev
command: celery -A ypovoli worker -l DEBUG
volumes:
- $BACKEND_DIR:/code
depends_on:
- backend
- redis

frontend:
<<: *common-keys-selab
container_name: frontend
build:
context: $FRONTEND_DIR
dockerfile: Dockerfile.dev
command: bash -c "npm install && npm run host"
expose:
- 5173
volumes:
- $FRONTEND_DIR:/app
depends_on:
- backend
frontend:
<<: *common-keys-selab
container_name: frontend
build:
context: $FRONTEND_DIR
dockerfile: Dockerfile.dev
command: bash -c "npm install && npm run host"
expose:
- 5173
volumes:
- $FRONTEND_DIR:/app
depends_on:
- backend

redis:
<<: *common-keys-selab
container_name: redis
image: redis:latest
networks:
selab_network:
ipv4_address: $REDIS_IP
expose:
- $REDIS_PORT
entrypoint: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
volumes:
- ${DATA_DIR}/redis:/data
redis:
<<: *common-keys-selab
container_name: redis
image: redis:latest
networks:
selab_network:
ipv4_address: $REDIS_IP
expose:
- $REDIS_PORT
entrypoint: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
volumes:
- ${DATA_DIR}/redis:/data

cypress:
<<: *common-keys-selab
container_name: cypress
image: cypress/included:cypress-12.17.3-node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
restart: "no"
working_dir: /e2e
volumes:
- ${FRONTEND_DIR}:/e2e
extra_hosts:
- "host.docker.internal:host-gateway"
cypress:
<<: *common-keys-selab
container_name: cypress
image: cypress/included:cypress-12.17.3-node-18.16.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
restart: "no"
working_dir: /e2e
volumes:
- ${FRONTEND_DIR}:/e2e
extra_hosts:
- "host.docker.internal:host-gateway"

0 comments on commit 4a83e9b

Please sign in to comment.