From 6bc5f182f3c1fd4012a4ec8096fcccff1f50364e Mon Sep 17 00:00:00 2001 From: CJ_Clippy Date: Mon, 6 Oct 2025 07:23:24 -0800 Subject: [PATCH] combine into one compose --- ansible/roles/our/tasks/stack.yml | 54 +++++++++++++--------------- services/our/compose.db.yaml | 21 ----------- services/our/compose.production.yaml | 37 +++++++++++++++++-- 3 files changed, 60 insertions(+), 52 deletions(-) diff --git a/ansible/roles/our/tasks/stack.yml b/ansible/roles/our/tasks/stack.yml index 0219cb1..6465ce9 100644 --- a/ansible/roles/our/tasks/stack.yml +++ b/ansible/roles/our/tasks/stack.yml @@ -7,7 +7,7 @@ - name: Add a docker network community.docker.docker_network: - name: spooky + name: our scope: swarm state: present driver: overlay @@ -28,32 +28,20 @@ dest: "/etc/futureporn/our/{{ item }}" mode: "0744" loop: - - compose.db.yaml - compose.production.yaml - - compose.green.yaml - - compose.blue.yaml -- name: Deploy db stack +- name: Deploy stack community.docker.docker_stack: state: present - name: our-postgres + name: our compose: - - /etc/futureporn/our/compose.db.yaml + - /etc/futureporn/our/compose.production.yaml - services: postgres: environment: POSTGRES_USER: "{{ lookup('dotenv', 'POSTGRES_USER', file='../../../../.env.production') }}" POSTGRES_PASSWORD: "{{ lookup('dotenv', 'POSTGRES_PASSWORD', file='../../../../.env.production') }}" POSTGRES_DB: "{{ lookup('dotenv', 'POSTGRES_DB', file='../../../../.env.production') }}" - -- name: Deploy stack to green - community.docker.docker_stack: - state: present - name: our-green - compose: - - /etc/futureporn/our/compose.production.yaml - - /etc/futureporn/our/compose.green.yaml - - services: worker: environment: DATABASE_URL: "{{ lookup('dotenv', 'DATABASE_URL', file='../../../../.env.production') }}" @@ -78,19 +66,27 @@ SEEDBOX_SFTP_URL: "{{ lookup('dotenv', 'SEEDBOX_SFTP_URL', file='../../../../.env.production') }}" SEEDBOX_SFTP_USERNAME: "{{ lookup('dotenv', 'SEEDBOX_SFTP_USERNAME', file='../../../../.env.production') }}" SEEDBOX_SFTP_PASSWORD: "{{ lookup('dotenv', 'SEEDBOX_SFTP_PASSWORD', file='../../../../.env.production') }}" - server: environment: DATABASE_URL: "{{ lookup('dotenv', 'DATABASE_URL', file='../../../../.env.production') }}" - -- name: Deploy stack to blue - community.docker.docker_stack: - state: present - name: our-blue - compose: - - /etc/futureporn/our/compose.production.yaml - - /etc/futureporn/our/compose.blue.yaml -# - name: Remove stack -# community.docker.docker_stack: -# name: mystack -# state: absent + NODE_ENV: "{{ lookup('dotenv', 'NODE_ENV', file='../../../../.env.production') }}" + ORIGIN: "{{ lookup('dotenv', 'ORIGIN', file='../../../../.env.production') }}" + PATREON_API_ORIGIN: "{{ lookup('dotenv', 'PATREON_API_ORIGIN', file='../../../../.env.production') }}" + PATREON_AUTHORIZE_PATH: "{{ lookup('dotenv', 'PATREON_AUTHORIZE_PATH', file='../../../../.env.production') }}" + PATREON_TOKEN_PATH: "{{ lookup('dotenv', 'PATREON_TOKEN_PATH', file='../../../../.env.production') }}" + PATREON_CLIENT_ID: "{{ lookup('dotenv', 'PATREON_CLIENT_ID', file='../../../../.env.production') }}" + PATREON_CLIENT_SECRET: "{{ lookup('dotenv', 'PATREON_CLIENT_SECRET', file='../../../../.env.production') }}" + COOKIE_SECRET: "{{ lookup('dotenv', 'COOKIE_SECRET', file='../../../../.env.production') }}" + S3_REGION: "{{ lookup('dotenv', 'S3_REGION', file='../../../../.env.production') }}" + S3_BUCKET: "{{ lookup('dotenv', 'S3_BUCKET', file='../../../../.env.production') }}" + S3_APPLICATION_KEY: "{{ lookup('dotenv', 'S3_APPLICATION_KEY', file='../../../../.env.production') }}" + S3_KEY_ID: "{{ lookup('dotenv', 'S3_KEY_ID', file='../../../../.env.production') }}" + S3_ENDPOINT: "{{ lookup('dotenv', 'S3_ENDPOINT', file='../../../../.env.production') }}" + CDN_ORIGIN: "{{ lookup('dotenv', 'CDN_ORIGIN', file='../../../../.env.production') }}" + CDN_TOKEN_SECRET: "{{ lookup('dotenv', 'CDN_TOKEN_SECRET', file='../../../../.env.production') }}" + WHISPER_DIR: "{{ lookup('dotenv', 'WHISPER_DIR', file='../../../../.env.production') }}" + B2_APPLICATION_KEY_ID: "{{ lookup('dotenv', 'B2_APPLICATION_KEY_ID', file='../../../../.env.production') }}" + B2_APPLICATION_KEY: "{{ lookup('dotenv', 'B2_APPLICATION_KEY', file='../../../../.env.production') }}" + SEEDBOX_SFTP_URL: "{{ lookup('dotenv', 'SEEDBOX_SFTP_URL', file='../../../../.env.production') }}" + SEEDBOX_SFTP_USERNAME: "{{ lookup('dotenv', 'SEEDBOX_SFTP_USERNAME', file='../../../../.env.production') }}" + SEEDBOX_SFTP_PASSWORD: "{{ lookup('dotenv', 'SEEDBOX_SFTP_PASSWORD', file='../../../../.env.production') }}" diff --git a/services/our/compose.db.yaml b/services/our/compose.db.yaml index 40f92af..b68a7a5 100644 --- a/services/our/compose.db.yaml +++ b/services/our/compose.db.yaml @@ -7,27 +7,6 @@ services: # protocol: tcp # mode: ingress - postgres: - image: postgres:17 - volumes: - - pgdata:/var/lib/postgresql/data - healthcheck: - test: ["CMD", "pg_isready", "-U", "postgres"] - interval: 10s - retries: 5 - start_period: 10s - timeout: 10s - deploy: - replicas: 1 - restart_policy: - condition: on-failure - delay: 5s - max_attempts: 5 - window: 60s - -volumes: - pgdata: - networks: default: external: true diff --git a/services/our/compose.production.yaml b/services/our/compose.production.yaml index f96f88a..3ac34c6 100644 --- a/services/our/compose.production.yaml +++ b/services/our/compose.production.yaml @@ -6,7 +6,11 @@ services: sh -c "npx prisma migrate deploy && npm run start:server" volumes: - /mnt/vfs/futureporn:/mnt/vfs/futureporn - # blue/green ports get published in those respective compose fragments + ports: + - target: 5000 # container port + published: 8086 # Swarm ingress port + protocol: tcp + mode: ingress worker: image: gitea.futureporn.net/futureporn/our:latest @@ -36,7 +40,36 @@ services: volumes: - /mnt/vfs/futureporn:/mnt/vfs/futureporn + postgres: + image: postgres:17 + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD", "pg_isready", "-U", "postgres"] + interval: 10s + retries: 5 + start_period: 10s + timeout: 10s + deploy: + replicas: 1 + restart_policy: + condition: on-failure + delay: 5s + max_attempts: 5 + window: 60s + + # pgadmin: + # image: dpage/pgadmin4:latest + # ports: + # - target: 5050 + # published: 8095 + # protocol: tcp + # mode: ingress + +volumes: + pgdata: + networks: default: external: true - name: spooky + name: our