cd ~
curl -Ls https://gist.github.com/raw/32c5c7be014ed26039a864f077dbff6f/setup.sh | bashLogout and in again to apply the changed groups!
| version: "3.7" | |
| services: | |
| traefik: | |
| image: traefik:v2.3 | |
| container_name: traefik | |
| restart: unless-stopped | |
| ports: | |
| - 80:80 | |
| - 443:443 | |
| - 127.0.0.1:8080:8080 | |
| command: | |
| - "--api.insecure=false" | |
| - "--providers.docker=true" | |
| - "--providers.docker.exposedbydefault=false" | |
| - "--entrypoints.web.address=:80" | |
| - "--entrypoints.webs.address=:443" | |
| - "--certificatesresolvers.le.acme.httpchallenge=true" | |
| - "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web" | |
| - "--certificatesresolvers.le.acme.email=youremail@example.com" | |
| - "--certificatesresolvers.le.acme.storage=/acme.json" | |
| # remove the following, once your setup works | |
| - "--certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory" | |
| volumes: | |
| - /var/run/docker.sock:/var/run/docker.sock | |
| - $PWD/traefik/acme.json:/acme.json | |
| traefik-certs-dumper: | |
| container_name: traefik_certs_dumper | |
| image: ldez/traefik-certs-dumper:v2.7.4 | |
| restart: unless-stopped | |
| entrypoint: sh -c ' | |
| apk add jq | |
| ; while ! [ -e /data/acme.json ] | |
| || ! [ `jq ".[] | .Certificates | length" /data/acme.json` != 0 ]; do | |
| sleep 1 | |
| ; done | |
| && traefik-certs-dumper file --version v2 --domain-subdir=true --watch | |
| --source /data/acme.json --dest /data/certs' | |
| volumes: | |
| - $PWD/traefik:/data | |
| hello: | |
| image: tutum/hello-world | |
| container_name: hello-world | |
| restart: unless-stopped | |
| labels: | |
| - "traefik.enable=true" | |
| - "traefik.http.routers.hello.rule=Host(`example.duckdns.org`)" | |
| - "traefik.http.routers.hello.entrypoints=webs" | |
| - "traefik.http.routers.hello.tls.certresolver=le" |
| #!/bin/bash | |
| sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y nano cron apt-transport-https ca-certificates gnupg-agent software-properties-common | |
| # install docker | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
| sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
| sudo apt-get update && sudo apt-get install -y docker-ce docker-ce-cli containerd.io | |
| sudo usermod -aG docker $USER | |
| # install docker-compose | |
| sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
| sudo chmod +x /usr/local/bin/docker-compose | |
| # prepare duckdns | |
| mkdir -p ~/duckdns | |
| echo -e "#!/bin/bash\nDOMAIN=example.duckdns.org\nTOKEN=aaaaaaaa-1111-1111-1111-111111111111\n\necho url=\"https://www.duckdns.org/update?domains=\${DOMAIN}&token=\${TOKEN}&ip=\" | curl -k -o ~/duckdns/duck.log -K -\n" > ~/duckdns/duck.sh | |
| chmod 700 ~/duckdns/duck.sh | |
| # install cron job for duckdns | |
| # write out current crontab | |
| crontab -l > ~/duckdns/cronjob | |
| # echo new cron into cron file | |
| echo "*/5 * * * * ~/duckdns/duck.sh >/dev/null 2>&1" >> ~/duckdns/cronjob | |
| # install new cron file | |
| crontab ~/duckdns/cronjob | |
| rm ~/duckdns/cronjob | |
| # get docker-compose example | |
| mkdir -p ~/cloud | |
| curl -Ls https://gist.github.com/raw/32c5c7be014ed26039a864f077dbff6f/docker-compose.yml -o ~/cloud/docker-compose.yml | |
| # prepare traefik stroage | |
| mkdir -p ~/cloud/traefik | |
| echo "{}" > ~/cloud/traefik/acme.json | |
| sudo chmod 600 ~/cloud/traefik/acme.json | |
| # final info | |
| echo -e "\n\n" | |
| echo "Installation is done!" | |
| echo "You need to adapt the following files:" | |
| echo " ~/duckdns/duck.sh" | |
| echo " ~/cloud/docker-compose.yml" | |
| echo "Start:" | |
| echo " cd ~/cloud" | |
| echo " docker-compose up" |