Simplify startup script

This commit is contained in:
Keannu Bernasol 2024-08-30 21:57:49 +08:00
parent 07afe51618
commit 3d14d227a7
4 changed files with 7 additions and 15 deletions

View file

@ -24,9 +24,9 @@ steps:
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config
- ssh root@10.0.10.4 '
cd "/mnt/nvme/files/docker projects/DRF-Template";
docker-compose down;
docker-compose -f docker-compose.demo.yml down;
docker image rm git.keannu1.duckdns.org/keannu125/drf_template || true;
docker pull git.keannu1.duckdns.org/keannu125/drf_template:latest;
docker volume rm "git.keannu1.duckdns.org/keannu125/drf_template_db_data" || true;
docker compose up -f docker-compose.prod.yml -d;'
docker compose -f docker-compose.demo.yml up -d;'
secrets: [SSH_KEY]

View file

@ -3,13 +3,8 @@ FROM python:3.11.4-bookworm
ENV PYTHONBUFFERED 1
ENV DEBIAN_FRONTEND noninteractive
RUN mkdir /code
WORKDIR /code
# Directory mirroring
ADD . /code/
COPY . /code/
COPY start.sh /code/
RUN chmod +x /code/start.sh
# Install packages
RUN apt-get update && apt-get install -y graphviz libgraphviz-dev graphviz-dev wget zip

View file

@ -6,12 +6,12 @@ services:
env_file: .env
image: git.keannu1.duckdns.org/keannu125/drf_template:latest
ports:
- "${BACKEND_PORT}:${BACKEND_PORT}"
- "${BACKEND_PORT}:8000"
environment:
- PYTHONBUFFERED=1
- RUN_TYPE=web
volumes:
- .:/code
- ./backend/static:/backend/static
depends_on:
- postgres
@ -22,7 +22,6 @@ services:
- RUN_TYPE=worker
image: git.keannu1.duckdns.org/keannu125/drf_template:latest
volumes:
- .:/code
- ./chrome:/chrome
- ./firefox:/firefox
- ./dumps:/dumps
@ -30,7 +29,7 @@ services:
- django
- postgres
- redis
## Runs multiple worker instances
# Run multiple worker instances
scale: 4
# Django Celery Beat

View file

@ -1,8 +1,6 @@
#!/bin/bash
# read .env values
awk -F= '$1 == "BACKEND_DEBUG" {print $2}' .env
awk -F= '$1 == "BACKEND_PORT" {print $2}' .env
awk -F= '$1 == "CELERY_FLOWER_PORT" {print $2}' .env
echo "Running as: $RUN_TYPE"
cd backend/
@ -15,9 +13,9 @@ if [ "$RUN_TYPE" = "web" ]; then
python manage.py collectstatic --noinput
fi
if [ "$BACKEND_DEBUG" = 'True' ]; then
python manage.py runserver "0.0.0.0:${BACKEND_PORT:-8000}"
python manage.py runserver "0.0.0.0:8000"
else
python -m granian --host 0.0.0.0 --port "${BACKEND_PORT:-8000}" --workers 8 --interface wsgi config.wsgi:application
python -m granian --host 0.0.0.0 --port 8000 --workers 8 --interface wsgi config.wsgi:application
fi
elif [ "$RUN_TYPE" = "worker" ]; then
celery -A config worker -l INFO -E --concurrency 1