Skip to content

Instantly share code, notes, and snippets.

@kurosabo
Created October 1, 2023 13:18
Show Gist options
  • Save kurosabo/664f58d814a38a230c4166291c963b52 to your computer and use it in GitHub Desktop.
Save kurosabo/664f58d814a38a230c4166291c963b52 to your computer and use it in GitHub Desktop.
https nginx without cron and edit config
version: "3.9"
services:
lego-init:
image: goacme/lego:latest
entrypoint: '
sh -c "
/lego --path /certs list --names | grep -F ${LEGO_DOMAIN}
|| /lego
--path /certs
--dns route53
--email ${LEGO_MAIL}
--domains "*.${LEGO_DOMAIN}"
--domains "${LEGO_DOMAIN}"
--accept-tos
run" '
command: ""
volumes:
- certs:/certs
environment:
- AWS_CONFIG_FILE=/run/secrets/aws_config
- AWS_SHARED_CREDENTIALS_FILE=/run/secrets/aws_credentials
secrets:
- aws_config
- aws_credentials
lego-renew:
image: goacme/lego:latest
entrypoint: '
sh -c "trap exit TERM;
while :;
do
/lego
--path /certs
--dns route53
--email ${LEGO_MAIL}
--domains "*.${LEGO_DOMAIN}"
--domains "${LEGO_DOMAIN}"
--accept-tos
renew
--days 15 ;
sleep 12h & wait $${!};
done;" '
command: ""
volumes:
- certs:/certs
environment:
- AWS_CONFIG_FILE=/run/secrets/aws_config
- AWS_SHARED_CREDENTIALS_FILE=/run/secrets/aws_credentials
secrets:
- aws_config
- aws_credentials
restart: unless-stopped
depends_on:
lego-init:
condition: service_completed_successfully
nginx:
image: nginx:stable
ports:
- 80:80
- 443:443
volumes:
- certs:/certs
- ./nginx/conf.d:/etc/nginx/conf.d:ro
restart: unless-stopped
depends_on:
lego-init:
condition: service_completed_successfully
volumes:
certs:
secrets:
aws_config:
file: aws_config
aws_credentials:
file: secret_aws_credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment