From af4cdb91411919ff3b3830b45e96bce032007712 Mon Sep 17 00:00:00 2001 From: Ilya Mukhortov Date: Wed, 28 Sep 2022 09:59:16 +1000 Subject: [PATCH] pass --- Readme.md | 11 ++++++ examples/run.sh | 37 ++++++++++++++++++ examples/second-instance.yml | 76 ++++++++++++++++++++++++++++++++++++ medicine/run.sh | 1 + tfoms-patient/update.sh | 5 +++ 5 files changed, 130 insertions(+) create mode 100644 examples/run.sh create mode 100644 examples/second-instance.yml create mode 100644 tfoms-patient/update.sh diff --git a/Readme.md b/Readme.md index 3b278fa..e5a31ac 100644 --- a/Readme.md +++ b/Readme.md @@ -37,3 +37,14 @@ > service ssh restart +### Обратный ssh +на удаленном сервере + + ssh -R 40022:localhost:22 proxy_user@188.225.79.4 + +на доступном сервере + + ssh localhost -p 40022 + + +Aa$#123490 \ No newline at end of file diff --git a/examples/run.sh b/examples/run.sh new file mode 100644 index 0000000..5ed7196 --- /dev/null +++ b/examples/run.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + +COMMAND="$1" +ARGUMENT="$2" + +pull_images() { + echo "readonly" | docker login docker.med-logic.ru --username readonly --password-stdin + docker pull docker.med-logic.ru/medicine-app:latest + docker pull docker.med-logic.ru/medicine-nginx:latest +} + +post_update() { + docker-compose run --rm app python manage.py migrate directory --noinput + docker-compose run --rm app python manage.py directory_importdata all + docker-compose run --rm app python manage.py migrate --noinput + docker-compose run --rm app python manage.py collectstatic --noinput + docker-compose run --rm app python manage.py post_update +} + +docker_cleanup() { + docker rmi $(docker images -f "dangling=true" -q) +} + +update() { + pull_images + + docker-compose stop + docker-compose up -d + + post_update + + docker_cleanup +} + +${COMMAND} \ No newline at end of file diff --git a/examples/second-instance.yml b/examples/second-instance.yml new file mode 100644 index 0000000..c0bb4ab --- /dev/null +++ b/examples/second-instance.yml @@ -0,0 +1,76 @@ +version: '3' + +services: + + nginx: + image: docker.med-logic.ru/medicine-nginx:latest + container_name: medicine2-nginx + restart: "always" + volumes: + - medicine-public-data:/app/public:ro + links: + - "app:app-host" + ports: + - "810:80" + - "811:443" + networks: + - default + - medicine-network + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" + + app: + image: docker.med-logic.ru/medicine-app:latest + container_name: medicine2-app + restart: "always" + environment: + UWSGI_PROCESSES: 2 + UWSGI_THREADS: 2 + expose: + - "840" + command: /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf + volumes: + - medicine-public-data:/app/public + - ./.env:/app/.env + networks: + - default + - medicine-network + external_links: + - "postgres:postgres-host" + - "redis:redis-host" + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" + + tasks: + image: docker.med-logic.ru/medicine-app:latest + container_name: medicine2-tasks + restart: "always" + command: /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord-tasks.conf + volumes: + - ./.env:/app/.env + - medicine-public-data:/app/public + networks: + - default + - medicine-network + external_links: + - "postgres:postgres-host" + - "redis:redis-host" + logging: + driver: "json-file" + options: + max-size: "200k" + max-file: "10" + +volumes: + medicine-public-data: + +networks: + medicine-network: + external: + name: "medicine-network" \ No newline at end of file diff --git a/medicine/run.sh b/medicine/run.sh index 3e00250..6932292 100644 --- a/medicine/run.sh +++ b/medicine/run.sh @@ -24,6 +24,7 @@ backup_database() { post_update() { docker-compose run --rm app python manage.py migrate --noinput docker-compose run --rm app python manage.py directory_importdata all + docker-compose run --rm app python manage.py collectstatic --noinput docker-compose run --rm app python manage.py post_update } diff --git a/tfoms-patient/update.sh b/tfoms-patient/update.sh new file mode 100644 index 0000000..cf33c5b --- /dev/null +++ b/tfoms-patient/update.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +docker-compose stop +docker-compose pull +docker-compose up -d