Compare commits

..

1 Commits

Author SHA1 Message Date
62665a67b7
Deploy a simple webserver docker-compose stack
The beginning of a revamp of FRITA infrastructure into containers
2022-11-18 02:44:05 -05:00
3 changed files with 5 additions and 62 deletions

View File

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

View File

@ -1,56 +1,30 @@
version: '3.5' version: '3.5'
volumes:
wordpress:
networks: networks:
traefik: traefik:
name: traefik name: traefik
services: services:
traefik: traefik:
image: traefik:${TRAEFIK_VERSION:-latest} image: traefik:2.2
restart: always
command: command:
- --api.dashboard=${TRAEFIK_DASHBOARD:-true} - --api.dashboard=true
- --api.debug=${TRAEFIK_DEBUG:-true} - --api.debug=true
- --providers.docker=true - --providers.docker=true
- --providers.docker.exposedbydefault=${TRAEFIK_EXPOSED_DEFAULT:-false}
- --entrypoints.web.address=:80 - --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=websecure - --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https - --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.web.http.redirections.entrypoint.permanent=true - --entrypoints.web.http.redirections.entrypoint.permanent=true
- --entrypoints.websecure.address=:443 - --entrypoints.websecure.address=:443
- --entrypoints.local.address=:8443
ports: ports:
- 80:80 - 80:80
- 443:443 - 443:443
- "127.0.0.1:8443:8443"
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
labels: labels:
traefik.http.routers.api.rule: Host(`${TRAEFIK_DOMAIN:-traefik.local.freeitathens.org}`) traefik.http.routers.api.rule: Host(`${TRAEFIK_DOMAIN}`)
traefik.http.routers.api.entrypoints: local traefik.http.routers.api.entrypoints: local
traefik.http.routers.api.service: api@internal traefik.http.routers.api.service: api@internal
traefik.http.routers.api.tls: true traefik.http.routers.api.tls: true
traefik.enable: true
networks: networks:
- traefik - 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

View File

@ -1,31 +0,0 @@
#!/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