Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always restart containers in prod #45

Merged
merged 3 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions bin/provision-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,28 @@ usermod -aG docker rocky

# Adjust selinux
setenforce Enforcing

# Ensure Freezing Saddles site comes up on reboot
# It runs with Docker Compose so this should be sufficient.
# nginx was not starting as expected sometimes.
# https://github.com/freezingsaddles/freezing-compose/issues/5
#
# Thanks https://unix.stackexchange.com/a/271666 for inspiration
# shellcheck disable=SC2154
cat > /usr/local/bin/restart-on-reboot.sh <<EOF
#!/usr/bin/env bash
set -euo pipefail
if [[ -d /opt/compose ]]; then
(
cd /opt/compose
sleep 60
docker compose ps
docker compose up -d
docker compose ps
) 2>&1 | logger -t freezingsaddles
fi
EOF
chmod 750 /usr/local/bin/restart-on-reboot.sh
crontab <<EOF
@reboot /usr/local/bin/restart-on-reboot.sh
EOF
17 changes: 10 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ services:
container_name: beanstalkd
volumes:
- beanstalkd-data:/data
restart: unless-stopped
restart: always
logging:
driver: awslogs
options:
Expand All @@ -67,7 +67,8 @@ services:
- 'nginx-webroot:/usr/share/nginx/html'
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
restart: unless-stopped
- "com.github.nginx-proxy.nginx"
restart: always
logging:
driver: awslogs
options:
Expand All @@ -92,12 +93,14 @@ services:
- 'nginx-config:/etc/nginx/conf.d'
- 'nginx-vhosts:/etc/nginx/vhost.d'
- 'nginx-webroot:/usr/share/nginx/html'
restart: unless-stopped
restart: always
logging:
driver: awslogs
options:
awslogs-group: logspout
awslogs-stream: nginx-letsencrypt
depends_on:
- nginx

nginx-docker-gen:
image: jwilder/docker-gen
Expand All @@ -113,7 +116,7 @@ services:
- 'nginx-webroot:/usr/share/nginx/html'
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen"
restart: unless-stopped
restart: always
logging:
driver: awslogs
options:
Expand Down Expand Up @@ -154,7 +157,7 @@ services:
VISUAL_CROSSING_API_KEY: ${VISUAL_CROSSING_API_KEY}
volumes:
- ./sync-data:/data
restart: unless-stopped
restart: always
logging:
driver: awslogs
options:
Expand All @@ -174,7 +177,7 @@ services:
LETSENCRYPT_HOST: ${FREEZING_NQ_FQDN}
STRAVA_VERIFY_TOKEN: ${STRAVA_VERIFY_TOKEN}
VIRTUAL_HOST: ${FREEZING_NQ_FQDN}
restart: unless-stopped
restart: always
logging:
driver: awslogs
options:
Expand Down Expand Up @@ -208,7 +211,7 @@ services:
TEAMS: ${TEAMS}
TIMEZONE: ${TIMEZONE:-America/New_York}
VIRTUAL_HOST: ${FREEZING_WEB_FQDN}
restart: unless-stopped
restart: always
logging:
driver: awslogs
options:
Expand Down
Loading