From 8df524c9d5dd8039ac2c46deaa07fe8aa541ca66 Mon Sep 17 00:00:00 2001 From: Teck Meng Date: Tue, 4 Jun 2024 19:38:27 +0800 Subject: [PATCH] Refactor makefile to separate loadenvs command in deploy-test target --- makefile | 41 +++++++++++++++++++++++++++++++---------- swarm/apps.yml | 49 +++++++++++++++++++++++-------------------------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/makefile b/makefile index fedf521..96af943 100644 --- a/makefile +++ b/makefile @@ -14,15 +14,32 @@ pull: @echo "Pulling the project..." git pull +deploy-core: pull + { \ + echo "Deploying the core stack..." ;\ + set -a ;\ + . ./swarm/.env ;\ + set +a ;\ + docker stack deploy --compose-file ./swarm/core.yml core ;\ + } + deploy-services: pull - @echo "Deploying the services stack..." - $(loadenvs ./swarm/.env) - docker stack deploy --compose-file ./swarm/services.yml services + { \ + echo "Deploying the services stack..." ;\ + set -a ;\ + . ./swarm/.env ;\ + set +a ;\ + docker stack deploy --compose-file ./swarm/services.yml services ;\ + } deploy-apps: pull - @echo "Deploying the apps stack..." - $(loadenvs ./swarm/.env) - docker stack deploy --compose-file ./swarm/apps.yml apps + { \ + echo "Deploying the apps stack..." ;\ + set -a ;\ + . ./swarm/.env ;\ + set +a ;\ + docker stack deploy --compose-file ./swarm/apps.yml apps ;\ + } deploy-ghost: pull { \ @@ -33,8 +50,12 @@ deploy-ghost: pull docker stack deploy --compose-file ./swarm/ghost.yml ghost ;\ } -deploy-test: pull - @echo "Deploying the test stack..." - $(loadenvs ./swarm/.env) - docker stack deploy --compose-file ./swarm/thelounge.yml thelounge +deploy-thelounge: pull + { \ + echo "Deploying the thelounge stack..." ;\ + set -a ;\ + . ./swarm/.env ;\ + set +a ;\ + docker stack deploy --compose-file ./swarm/thelounge.yml thelounge ;\ + } # git submodule update --init --recursive \ No newline at end of file diff --git a/swarm/apps.yml b/swarm/apps.yml index 017721b..c482870 100644 --- a/swarm/apps.yml +++ b/swarm/apps.yml @@ -5,12 +5,12 @@ x-environment: &app-environment STREAMLIT_BAI_SERVER_PORT: 8502 GROQ_API_KEY: "${GROQ_API_KEY}" -volumes: - bai_cache: {} - jellyfin_config: {} - jellyfin_cache: {} - pgadmin: {} - privatebin_data: {} +# volumes: + # bai_cache: {} + # jellyfin_config: {} + # jellyfin_cache: {} + # adminer_data: {} + # privatebin_data: {} networks: traefik-public: @@ -28,7 +28,7 @@ services: TZ: Asia/Singapore DOMAIN: ${DOMAIN} volumes: - - pgadmin:/var/lib/pgadmin + - /var/data/adminer_data:/var/lib/pgadmin restart: unless-stopped depends_on: - postgres_db @@ -91,8 +91,8 @@ services: - DOMAIN=${DOMAIN} - JELLYFIN_PublishedServerUrl=https://media.${DOMAIN} volumes: - - jellyfin_config:/config - - jellyfin_cache:/cache + - /var/data/jellyfin_config:/config + - /var/data/jellyfin_cache:/cache - type: bind source: ~/media target: /media @@ -101,10 +101,10 @@ services: networks: - traefik-public deploy: - placement: - constraints: - - node.labels.jellyfin.jellyfin_config == true - - node.labels.jellyfin.jellyfin_cache == true + # placement: + # constraints: + # - node.labels.jellyfin.jellyfin_config == true + # - node.labels.jellyfin.jellyfin_cache == true labels: - traefik.enable=true - traefik.docker.network=traefik-public @@ -138,16 +138,16 @@ services: image: privatebin/nginx-fpm-alpine:latest read_only: true volumes: - - privatebin_data:/srv/data # data volume for pastes allows pastes + - /var/data/privatebin_data:/srv/data # data volume for pastes allows pastes # to persist after container stop or restart - - "~/config/conf.php:/srv/cfg/conf.php:ro" # second volume for custom configuration file + - "/var/data/config/conf.php:/srv/cfg/conf.php:ro" # second volume for custom configuration file restart: unless-stopped networks: - traefik-public deploy: - placement: - constraints: - - node.labels.privatebin.privatebin_data == true + # placement: + # constraints: + # - node.labels.privatebin.privatebin_data == true labels: - traefik.enable=true - traefik.docker.network=traefik-public @@ -165,13 +165,10 @@ services: restart: unless-stopped command: streamlit run --server.port=$STREAMLIT_BAI_SERVER_PORT --server.address=0.0.0.0 --server.baseUrlPath=$BAI_LOCATION src/app.py volumes: - - bai_cache:/app/cache + - /var/data/bai_cache:/app/cache networks: - traefik-public deploy: - # placement: - # constraints: - # - node.labels.bai.bai_cache == true labels: - traefik.enable=true - traefik.docker.network=traefik-public @@ -204,13 +201,13 @@ services: image: nginx:alpine restart: unless-stopped volumes: - - ~/site:/usr/share/nginx/html:ro + - var/data/site:/usr/share/nginx/html:ro networks: - traefik-public deploy: - placement: - constraints: - - node.labels.site.site_server == true + # placement: + # constraints: + # - node.labels.site.site_server == true labels: - traefik.enable=true - traefik.docker.network=traefik-public