Initial project structure
This commit is contained in:
19
docker/django/Dockerfile
Normal file
19
docker/django/Dockerfile
Normal 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"]
|
||||
20
docker/django/entrypoint.sh
Normal file
20
docker/django/entrypoint.sh
Normal 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
22
docker/docker-compose.yml
Normal 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
|
||||
Reference in New Issue
Block a user