Skip to content

Commit

Permalink
significantly simplify deployment->into 1 compose
Browse files Browse the repository at this point in the history
  • Loading branch information
tiptenbrink committed Nov 13, 2023
1 parent 9260609 commit 782cb39
Show file tree
Hide file tree
Showing 103 changed files with 700 additions and 9,225 deletions.
77 changes: 77 additions & 0 deletions build/deploy/compose/confspawn_docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
services:
# Service name, container name will be <project name>-<service name>-1 by default
{{ db.service_name }}:
profiles: [ "data", "all" ]
# Docker image that it will set up
image: "${DB_APP_IMAGE}:${DB_VERSION}"
# A volume is basically a file system shared between the host and the container
volumes:
# <volume name in volumes below>:<container destination directory>
# This means the volume will be accessible from the container in the dest. directory in the container
- {{ db.volume_name }}:${DB_RESOURCES_TARGET}
command: -c config_file=${DB_CONF_FILE}
# Some environment variables depend on deployment variables, so we load those in manually
environment:
- PGDATA=${DB_RESOURCES_TARGET}
- POSTGRES_PASSWORD
- POSTGRES_USER
# This maps ports, so the container port will be available at localhost:<HOST_PORT>
ports:
- "${DB_HOST_HOST}:${DB_HOST_PORT}:{{ db.container_port }}"
# Shared memory size, defaults to 64m which can cause problems (apparently)
shm_size: 256m
restart: {{ confspawn_env.restart }}
# healthcheck:
# test: "pg_isready -p {{ db.container_port }}"
# interval: 30s
# retries: 5
# start_period: 10s
# start_interval: 2s
# timeout: 10s
{{ kv.service_name }}:
profiles: [ "data", "all" ]
image: "${KV_IMAGE}:${KV_VERSION}"
ports:
- "${KV_HOST_HOST}:${KV_HOST_PORT}:{{ kv.container_port }}"
command: /bin/sh -c "redis-server --requirepass ${REDIS_PASSWORD}"
restart: {{ confspawn_env.restart }}
{{ server.service_name }}:
profiles: [ "all" ]
depends_on:
- {{ db.service_name }}
- {{ kv.service_name }}
# Docker image that it will set up
image: "${SERVER_IMAGE}:${SERVER_VERSION}"
# Some environment variables depend on deployment variables, so we load those in manually
environment:
- DB_PASS=${POSTGRES_PASSWORD}
- KV_PASS=${REDIS_PASSWORD}
- MAIL_PASS=${COMCOM_MAIL_PASS}
- KEY_PASS=${KEY_PASSWORD}
- RECREATE=${RECREATE}
# This maps ports, so the container port will be available at localhost:<HOST_PORT>
ports:
- "${SERVER_HOST_HOST}:${SERVER_HOST_PORT}:{{ server.container_port }}"
# Shared memory size, defaults to 64m which can cause problems (apparently)
shm_size: 256m
# This important for being able to send email when email has same ip as host
extra_hosts:
- "host.docker.internal:host-gateway"
restart: {{ confspawn_env.restart }}
# Prevent too large core dumps
ulimits:
core:
soft: 0
hard: 0
volumes:
# This name should correspond to the volume mentioned in volumes above
{{ db.volume_name }}:
# A local directory
driver: local
name: {{ db.volume_name }}-{{ confspawn_env.name }}
networks:
# Set up a network so that other containers on this network can access each other
# A different container on this network can access this container by using the container name as the hostname
# So localhost:3000 is exposed to other containers as <container name>:3000
default:
name: ${NETWORK_NAME}
21 changes: 0 additions & 21 deletions build/deploy/db/confspawn_deploy.env

This file was deleted.

46 changes: 0 additions & 46 deletions build/deploy/db/confspawn_deploy.sh

This file was deleted.

14 changes: 0 additions & 14 deletions build/deploy/db/down.sh

This file was deleted.

44 changes: 37 additions & 7 deletions build/deploy/dev/confspawn_dev.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
POSTGRES_PASSWORD=postpost
REDIS_PASSWORD=redisredis
BARMAN_PASSWORD=barbar
RECREATE=no
DB_VERSION=localdev
KV_VERSION=localdev
SERVER_VERSION={{ confspawn_env.version }}
# The docker compose project name
COMPOSE_PROJECT_NAME={{ main.project }}
NETWORK_NAME={{ main.docker_net_name }}

# This .env file contains environment variables used during deployment
# The host port will be the port that the host will open, i.e. what nginx will connect to. Hostname defined by HOST_HOST
KV_HOST_HOST=127.0.0.1
DB_HOST_HOST=127.0.0.1
SERVER_HOST_HOST=127.0.0.1

REDIS_PASSWORD={{ confspawn_env.kv_password }}
# The tag to upload to GHCR to
KV_IMAGE={{ kv.image_name }}
# Docker tag version
KV_VERSION={{ confspawn_env.version }}
# The host port will be the port that the host will open, i.e. what nginx will connect to. Hostname defined by HOST_HOST
KV_HOST_PORT={{ kv.host_port }}

POSTGRES_PASSWORD={{ confspawn_env.db_password }}
# The tag to upload to GHCR to
DB_APP_IMAGE={{ db.image_name }}
# Docker tag version
DB_VERSION={{ confspawn_env.version }}
DB_HOST_PORT={{ db.host_port }}
# This is the directory that the resources will be loaded into in the container
DB_RESOURCES_TARGET={{ db.resources_target }}
DB_CONF_FILE={{ db.postgres_conf_dir }}/postgresql.conf
POSTGRES_USER={{ db.db_user }}

SERVER_IMAGE={{ server.image_name }}
SERVER_VERSION={{ confspawn_env.version }}
# The host port will be the port that the host will open, i.e. what nginx will connect to. Hostname defined by HOST_HOST
SERVER_HOST_PORT={{ server.host_port }}
COMCOM_MAIL_PASS=""
KEY_PASSWORD="AT_av0v62Z3hQH50VYwKBks1-VSukK9xDN_Ur34mdZ4"

RECREATE=no
43 changes: 35 additions & 8 deletions build/deploy/dev/confspawn_dev_port.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
POSTGRES_PASSWORD=postpost
# The docker compose project name
COMPOSE_PROJECT_NAME={{ main.project }}
NETWORK_NAME={{ main.docker_net_name }}

# This .env file contains environment variables used during deployment
# The host port will be the port that the host will open, i.e. what nginx will connect to. Hostname defined by HOST_HOST
KV_HOST_HOST=0.0.0.0
DB_HOST_HOST=0.0.0.0
SERVER_HOST_HOST=0.0.0.0

REDIS_PASSWORD=redisredis
BARMAN_PASSWORD=barbar
RECREATE=no
DB_VERSION=localdev
KV_VERSION=localdev
# The tag to upload to GHCR to
KV_IMAGE={{ kv.image_name }}
# Docker tag version
KV_VERSION={{ confspawn_env.version }}
# The host port will be the port that the host will open, i.e. what nginx will connect to. Hostname defined by HOST_HOST
KV_HOST_PORT={{ kv.host_port }}

POSTGRES_PASSWORD=postpost
# The tag to upload to GHCR to
DB_APP_IMAGE={{ db.image_name }}
# Docker tag version
DB_VERSION={{ confspawn_env.version }}
DB_HOST_PORT={{ db.host_port }}
# This is the directory that the resources will be loaded into in the container
DB_RESOURCES_TARGET={{ db.resources_target }}
DB_CONF_FILE={{ db.postgres_conf_dir }}/postgresql.conf
POSTGRES_USER={{ db.db_user }}

SERVER_IMAGE={{ server.image_name }}
SERVER_VERSION={{ confspawn_env.version }}
DB_HOST_HOST=0.0.0.0
KV_HOST_HOST=0.0.0.0
SERVER_HOST_HOST=0.0.0.0
# The host port will be the port that the host will open, i.e. what nginx will connect to. Hostname defined by HOST_HOST
SERVER_HOST_PORT={{ server.host_port }}
COMCOM_MAIL_PASS=""
KEY_PASSWORD="AT_av0v62Z3hQH50VYwKBks1-VSukK9xDN_Ur34mdZ4"

RECREATE=no
14 changes: 3 additions & 11 deletions build/deploy/dev/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@
config = "config.toml"

[[sources]]
source = "build/deploy/dev"
source = "build/deploy/compose"
target = "use/dev"

[[sources]]
source = "build/deploy/db"
target = "use/dev/db"

[[sources]]
source = "build/deploy/kv"
target = "use/dev/kv"

[[sources]]
source = "build/deploy/server"
target = "use/dev/server"
source = "build/deploy/dev"
target = "use/dev"
25 changes: 0 additions & 25 deletions build/deploy/dev/devdeploy.sh

This file was deleted.

10 changes: 0 additions & 10 deletions build/deploy/dev/down.sh

This file was deleted.

14 changes: 0 additions & 14 deletions build/deploy/kv/confspawn_deploy.env

This file was deleted.

52 changes: 0 additions & 52 deletions build/deploy/kv/confspawn_deploy.sh

This file was deleted.

Loading

0 comments on commit 782cb39

Please sign in to comment.