-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
32 lines (29 loc) · 1.32 KB
/
Copy pathdocker-compose.yml
File metadata and controls
32 lines (29 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
version: '3.8'
services:
nginx:
build: .
container_name: bp_nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./site:/usr/share/nginx/html:ro
- ./letsencrypt:/etc/letsencrypt
- ./site/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
restart: unless-stopped
certbot:
image: certbot/certbot:latest
container_name: bp_certbot
volumes:
- ./letsencrypt:/etc/letsencrypt
- ./site:/var/www/html
# This container will attempt renewal in a loop. For first-time issuance run the "certonly" command below manually.
entrypoint: ["sh","-c","while :; do certbot renew --webroot -w /var/www/html --quiet || true; sleep 12h; done"]
restart: unless-stopped
# Notes:
# 1) For initial certificate issuance (run once from the host):
# docker-compose run --rm certbot certonly --webroot -w /var/www/html -d basicprimitives.com -d www.basicprimitives.com --email you@example.com --agree-tos --no-eff-email
# 2) Add a host cron/systemd timer on the EC2 instance to run:
# docker-compose run --rm certbot renew --webroot -w /var/www/html --quiet && docker-compose exec nginx nginx -s reload
# (This will renew certs and reload nginx to pick up the new certs.)
# 3) The ./letsencrypt directory stores certs and must be persisted between deploys. Ensure it is on a persistent volume on EC2.