mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
Simplify startup script
This commit is contained in:
parent
07afe51618
commit
3d14d227a7
4 changed files with 7 additions and 15 deletions
|
@ -24,9 +24,9 @@ steps:
|
||||||
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config
|
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config
|
||||||
- ssh root@10.0.10.4 '
|
- ssh root@10.0.10.4 '
|
||||||
cd "/mnt/nvme/files/docker projects/DRF-Template";
|
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 image rm git.keannu1.duckdns.org/keannu125/drf_template || true;
|
||||||
docker pull git.keannu1.duckdns.org/keannu125/drf_template:latest;
|
docker pull git.keannu1.duckdns.org/keannu125/drf_template:latest;
|
||||||
docker volume rm "git.keannu1.duckdns.org/keannu125/drf_template_db_data" || true;
|
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]
|
secrets: [SSH_KEY]
|
||||||
|
|
|
@ -3,13 +3,8 @@ FROM python:3.11.4-bookworm
|
||||||
ENV PYTHONBUFFERED 1
|
ENV PYTHONBUFFERED 1
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
RUN mkdir /code
|
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
# Directory mirroring
|
|
||||||
ADD . /code/
|
|
||||||
COPY . /code/
|
COPY . /code/
|
||||||
COPY start.sh /code/
|
|
||||||
RUN chmod +x /code/start.sh
|
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
RUN apt-get update && apt-get install -y graphviz libgraphviz-dev graphviz-dev wget zip
|
RUN apt-get update && apt-get install -y graphviz libgraphviz-dev graphviz-dev wget zip
|
||||||
|
|
|
@ -6,12 +6,12 @@ services:
|
||||||
env_file: .env
|
env_file: .env
|
||||||
image: git.keannu1.duckdns.org/keannu125/drf_template:latest
|
image: git.keannu1.duckdns.org/keannu125/drf_template:latest
|
||||||
ports:
|
ports:
|
||||||
- "${BACKEND_PORT}:${BACKEND_PORT}"
|
- "${BACKEND_PORT}:8000"
|
||||||
environment:
|
environment:
|
||||||
- PYTHONBUFFERED=1
|
- PYTHONBUFFERED=1
|
||||||
- RUN_TYPE=web
|
- RUN_TYPE=web
|
||||||
volumes:
|
volumes:
|
||||||
- .:/code
|
- ./backend/static:/backend/static
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ services:
|
||||||
- RUN_TYPE=worker
|
- RUN_TYPE=worker
|
||||||
image: git.keannu1.duckdns.org/keannu125/drf_template:latest
|
image: git.keannu1.duckdns.org/keannu125/drf_template:latest
|
||||||
volumes:
|
volumes:
|
||||||
- .:/code
|
|
||||||
- ./chrome:/chrome
|
- ./chrome:/chrome
|
||||||
- ./firefox:/firefox
|
- ./firefox:/firefox
|
||||||
- ./dumps:/dumps
|
- ./dumps:/dumps
|
||||||
|
@ -30,7 +29,7 @@ services:
|
||||||
- django
|
- django
|
||||||
- postgres
|
- postgres
|
||||||
- redis
|
- redis
|
||||||
## Runs multiple worker instances
|
# Run multiple worker instances
|
||||||
scale: 4
|
scale: 4
|
||||||
|
|
||||||
# Django Celery Beat
|
# Django Celery Beat
|
6
start.sh
6
start.sh
|
@ -1,8 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# read .env values
|
# read .env values
|
||||||
awk -F= '$1 == "BACKEND_DEBUG" {print $2}' .env
|
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"
|
echo "Running as: $RUN_TYPE"
|
||||||
cd backend/
|
cd backend/
|
||||||
|
@ -15,9 +13,9 @@ if [ "$RUN_TYPE" = "web" ]; then
|
||||||
python manage.py collectstatic --noinput
|
python manage.py collectstatic --noinput
|
||||||
fi
|
fi
|
||||||
if [ "$BACKEND_DEBUG" = 'True' ]; then
|
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
|
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
|
fi
|
||||||
elif [ "$RUN_TYPE" = "worker" ]; then
|
elif [ "$RUN_TYPE" = "worker" ]; then
|
||||||
celery -A config worker -l INFO -E --concurrency 1
|
celery -A config worker -l INFO -E --concurrency 1
|
||||||
|
|
Loading…
Reference in a new issue