Initial project structure

This commit is contained in:
Roman Krček
2024-10-22 21:45:05 +02:00
commit c9a7535ef8
16 changed files with 268 additions and 0 deletions

19
docker/django/Dockerfile Normal file
View File

@@ -0,0 +1,19 @@
FROM python:3.11-slim AS base
WORKDIR /app
# Builder stage for downloading and installing packages
FROM base AS builder
COPY requirements.txt ./
RUN --mount=type=cache,target=/tmp/pip_cache \
python3 -m pip install --upgrade pip setuptools && \
python3 -m pip install \
-r requirements.txt \
--extra-index-url https://www.piwheels.org/simple \
--cache-dir /tmp/pip_cache
# Runtime stage for copying code and scripts
FROM base AS runtime
COPY --from=builder /usr/local/lib /usr/local/lib
COPY docker/entrypoint.sh ./
COPY orebolt_prevoid/ ./
ENTRYPOINT ["entrypoint.sh"]

View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Based on env variable PREVOID_RUN_MODE decide which service to start
if [ "$PREVOID_RUN_MODE" == "DJANGO" ]
python3 /app/manage.py runserver 0.0.0.0:8000
elif ["$PREVOID_RUN_MODE" == "CELERY"]
celery -A /app/orebolt_prevoid worker --loglevel=info
elif [ -z "$PREVOID_RUN_MODE" ]; then
echo "PREVOID_RUN_MODE is not set"
echo "Please set the PREVOID_RUN_MODE environment variable to DJANGO or CELERY."
sleep 5
exit 1
else
echo "Invalid value for PREVOID_RUN_MODE: $PREVOID_RUN_MODE"
echo "PREVOID_RUN_MODE must be either DJANGO or CELERY."
sleep 5
exit 1

22
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,22 @@
---
services:
django-server:
image: git.orebolt.ct/erman/orebolt-prevoid
restart: unless-stopped
environment:
PREVOID_RUN_MODE: "DJANGO"
PREVOID_REDIS_URL: "http://redis:6379/0"
ports:
- 8000:8000
celery-worker:
image: git.orebolt.ct/erman/orebolt-prevoid
restart: unless-stopped
environment:
PREVOID_RUN_MODE: "CELERY"
PREVOID_REDIS_URL: "http://redis:6379/0"
redis:
image: redis
restart: unless-stopped