Skip to content

Commit

Permalink
feat(deplyment): added poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Apr 2, 2024
1 parent 443aeb6 commit 54efb67
Show file tree
Hide file tree
Showing 10 changed files with 1,491 additions and 233 deletions.
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,284 changes: 1,284 additions & 0 deletions backend/poetry.lock

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[tool.poetry]
name = "backend"
version = "0.1.0"
description = ""
authors = ["Topvennie <vincent@vallaeys.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
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"


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

This file was deleted.

160 changes: 79 additions & 81 deletions development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,96 +3,94 @@ 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
ports:
- 80:80
- 443:443
- 8080: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
ports:
- 80:80
- 443:443
- 8080: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
Loading

0 comments on commit 54efb67

Please sign in to comment.