This commit is contained in:
Kris Lamoureux 2022-11-18 04:11:08 -05:00
parent 75ee5be87d
commit a2b26a978b
3 changed files with 57 additions and 2 deletions

View File

@ -2,4 +2,4 @@ docker_users:
- vagrant
webserver_env:
TRAEFIK_DOMAIN: traefik.example.org
TRAEFIK_DOMAIN: traefik.local.freeitathens.org

View File

@ -1,5 +1,8 @@
version: '3.5'
volumes:
wordpress:
networks:
traefik:
name: traefik
@ -7,10 +10,12 @@ networks:
services:
traefik:
image: traefik:${TRAEFIK_VERSION:-latest}
restart: always
command:
- --api.dashboard=${TRAEFIK_DASHBOARD:-true}
- --api.debug=${TRAEFIK_DEBUG:-false}
- --api.debug=${TRAEFIK_DEBUG:-true}
- --providers.docker=true
- --providers.docker.exposedbydefault=${TRAEFIK_EXPOSED_DEFAULT:-false}
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
@ -28,5 +33,24 @@ services:
traefik.http.routers.api.entrypoints: local
traefik.http.routers.api.service: api@internal
traefik.http.routers.api.tls: true
traefik.enable: true
networks:
- traefik
wordpress:
image: wordpress:${WORDPRESS_VERSION:-latest}
restart: always
environment:
WORDPRESS_DB_HOST: asdf
WORDPRESS_DB_USER: asdf
WORDPRESS_DB_PASSWORD: ASDFASDF
WORDPRESS_DB_NAME: ASDFA
labels:
traefik.http.routers.wordpress.rule: Host(`${WORDPRESS_DOMAIN:-www.local.freeitathens.org}`)
traefik.http.routers.wordpress.entrypoints: websecure
traefik.http.routers.wordpress.tls.certresolver: letsencrypt
traefik.docker.network: traefik
traefik.enable: true
volumes:
- wordpress:/var/www/html

31
update-hosts.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
COMMENT="FRITA-infra"
DOMAIN="local.freeitathens.org"
HOST[0]="traefik.${DOMAIN}"
HOST[1]="www.${DOMAIN}"
# Get Vagrantbox guest IP
VAGRANT_OUTPUT=$(vagrant ssh -c "hostname -I | cut -d' ' -f1" 2>/dev/null)
# Remove ^M from the end
[ ${#VAGRANT_OUTPUT} -gt 1 ] && IP=${VAGRANT_OUTPUT::-1}
echo "Purging project addresses from /etc/hosts"
sudo sed -i "s/# $COMMENT//g" /etc/hosts
for address in "${HOST[@]}"; do
sudo sed -i "/$address/d" /etc/hosts
done
# Remove trailing newline
sudo sed -i '${/^$/d}' /etc/hosts
if [ -n "$IP" ]; then
echo -e "Adding new addresses...\n"
echo -e "# $COMMENT" | sudo tee -a /etc/hosts
for address in "${HOST[@]}"; do
echo -e "$IP\t$address" | sudo tee -a /etc/hosts
done
else
echo "Cannot find address. Is the Vagrant box running?"
fi