|
1 | | -wip |
| 1 | +## What is this? |
| 2 | + |
| 3 | +Using a **one-liner**, this docker stack will run many services (Traefik (with auth), Socat, Portainer, Nginx, Caddy, Whoami) in a straightforward copy-paste command. |
| 4 | + |
| 5 | +You may also refer the [README](https://github.com/pascalandy/docker-stack-this/blob/master/README.md) at the root of this repo. |
| 6 | + |
| 7 | +## Start here |
| 8 | +1. Go to http://labs.play-with-docker.com/ |
| 9 | +2. Create **one** instance |
| 10 | +3. Copy-paste this one-liner: |
| 11 | + |
| 12 | +#### Stable setup (recommended) |
| 13 | + |
| 14 | +``` |
| 15 | +ENV_BRANCH="master" |
| 16 | +ENV_MONOREPO="traefik_stack5" |
| 17 | +
|
| 18 | +# On play-with-docker, install common apps |
| 19 | +apk update && apk upgrade && apk add --no-cache \ |
| 20 | + nano bash git curl wget unzip openssl tar ca-certificates && \ |
| 21 | +rm -rf /var/cache/apk/* /tmp* && \ |
| 22 | +docker swarm init --advertise-addr $(hostname -i) && \ |
| 23 | +git clone https://github.com/pascalandy/docker-stack-this.git && \ |
| 24 | +cd docker-stack-this && \ |
| 25 | +git checkout ${ENV_BRANCH} && \ |
| 26 | +cd ${ENV_MONOREPO} && \ |
| 27 | +./runup.sh; |
| 28 | +``` |
| 29 | + |
| 30 | +#### Edge setup (NOT recommended) |
| 31 | + |
| 32 | +``` |
| 33 | +ENV_BRANCH="edge" |
| 34 | +ENV_MONOREPO="traefik_stack6" |
| 35 | +
|
| 36 | +# On play-with-docker, install common apps |
| 37 | +apk update && apk upgrade && apk add --no-cache \ |
| 38 | + nano bash git curl wget unzip openssl tar ca-certificates && \ |
| 39 | +rm -rf /var/cache/apk/* /tmp* && \ |
| 40 | +docker swarm init --advertise-addr $(hostname -i) && \ |
| 41 | +git clone https://github.com/pascalandy/docker-stack-this.git && \ |
| 42 | +cd docker-stack-this && \ |
| 43 | +git checkout ${ENV_BRANCH} && \ |
| 44 | +cd ${ENV_MONOREPO} && \ |
| 45 | +./runup.sh; |
| 46 | +``` |
| 47 | + |
| 48 | +These scripts will do the hard of deploying the stacks for us. |
| 49 | + |
| 50 | +#### example |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +## See your stacks |
| 55 | + |
| 56 | +``` |
| 57 | +$ docker stack ls |
| 58 | +
|
| 59 | +NAME SERVICES ORCHESTRATOR |
| 60 | +toolgui 2 Swarm |
| 61 | +toolproxy 2 Swarm |
| 62 | +toolwebapp 4 Swarm |
| 63 | +``` |
| 64 | + |
| 65 | + |
| 66 | +## See your services |
| 67 | + |
| 68 | +``` |
| 69 | +$ docker service ls |
| 70 | +
|
| 71 | +ID NAME MODE REPLICAS IMAGE PORTS |
| 72 | +xjdsq3gxd59y toolgui_agent global 1/1 portainer/agent:latest |
| 73 | +0h375hmmnelo toolgui_portainer replicated 1/1 portainer/portainer:latest |
| 74 | +xim07ahqctsp toolproxy_socat replicated 1/1 devmtl/socatproxy:1.2 |
| 75 | +y249kaecel8e toolproxy_traefik replicated 1/1 traefik:1.7.12 *:80->80/tcp, *:443->443/tcp, *:8080->8080/tcp |
| 76 | +s0061fdhvv6o toolwebapp_home replicated 1/1 abiosoft/caddy:1.0.1-no-stats |
| 77 | +ocpk5l6yg2gt toolwebapp_who1 replicated 1/1 nginx:1.15-alpine |
| 78 | +raq5czrlhrmb toolwebapp_who2 replicated 1/1 emilevauge/whoami:latest |
| 79 | +66b1rduru5k9 toolwebapp_who3 replicated 1/1 emilevauge/whoami:latest |
| 80 | +``` |
| 81 | + |
| 82 | +## Confirm that your services (containers) are running |
| 83 | + |
| 84 | +1. When you see that all services are deployed, click on `80` to see the static landing page. |
| 85 | +2. From the same URL generated by play-with-docker, in the address bar of your browser, add `/who1` or `/who2` or `/who3` or `/portainer` to access other services. |
| 86 | + |
| 87 | + |
| 88 | +#### Full URL example |
| 89 | + |
| 90 | +``` |
| 91 | +http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/ |
| 92 | +http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who1 |
| 93 | +http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who2 |
| 94 | +http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who3 |
| 95 | +http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/portainer |
| 96 | +``` |
| 97 | + |
| 98 | +The container for the first URL is named `home`. |
| 99 | + |
| 100 | + |
| 101 | +#### Web apps details: |
| 102 | +- **/** = [caddy](https://github.com/pascalandy/caddy-securityheader) |
| 103 | +- **/who1** = [caddy](https://github.com/pascalandy/caddy-securityheader) |
| 104 | +- **/who2** = [whoami](https://hub.docker.com/r/emilevauge/whoami/) |
| 105 | +- **/portainer** = [portainer](https://hub.docker.com/r/portainer/portainer/) |
| 106 | + |
| 107 | +For /who1 and /who2 you will see the container's Ids (5fe91baf7a3a & 78a0c7287df1) in this example |
| 108 | + |
| 109 | +``` |
| 110 | +$ docker ps | grep whoami |
| 111 | +5fe91baf7a3a emilevauge/whoami:latest "/whoamI" About a minute ago Up About a minute 80/tcp toolwebapp_who3.1.9zk09prm85gnl0ieuuncynhxh |
| 112 | +78a0c7287df1 emilevauge/whoami:latest "/whoamI" About a minute ago Up About a minute 80/tcp toolwebapp_who2.1.wj7vf83ag91ft7jgdy3gwejp4 |
| 113 | +``` |
| 114 | + |
| 115 | + |
| 116 | +## How to access Traefik |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +#### Traefik password |
| 122 | + |
| 123 | +**user**: admin / **pass**: changethispass |
| 124 | + |
| 125 | +This password is encrypted in our configs `.configs/traefik.toml` |
| 126 | + |
| 127 | +To quickly generate yours with htpasswd, use my container: |
| 128 | + |
| 129 | +``` |
| 130 | +docker run --rm -it devmtl/alpinefire:3.8-D sh -c 'htpasswd -Bbn admin changethispass' |
| 131 | +``` |
| 132 | + |
| 133 | +This will display: |
| 134 | + |
| 135 | +``` |
| 136 | +admin:$2y$05$pAfipn3.brdHMI2eWGnYH.84XYqLozp1sUPi36/l54UAwv.zGLtNC |
| 137 | +``` |
| 138 | + |
| 139 | +Insert this string in your `.configs/traefik.toml`. |
| 140 | + |
| 141 | +#### What is Traefik? |
| 142 | + |
| 143 | +[Traefik](https://docs.traefik.io/configuration/backends/docker/) is a powerful layer 7 reverse proxy. Once running, the proxy will give you access to many web apps. I think this is a substantial use case to understand how this reverse-proxy works. |
| 144 | + |
| 145 | +#### Traefik version |
| 146 | + |
| 147 | +In `toolproxy.yml` look for something like `traefik:1.7.19`. |
| 148 | + |
| 149 | +#### Other stuff to know? |
| 150 | + |
| 151 | +- This stack does not use ACME (https://). ACME is a pain while developing … reaching limits, etc. |
| 152 | +- If you don’t want to use socat, check out the monorepo `traefik-manager-noacme` |
| 153 | + |
| 154 | +## Screenshots |
| 155 | + |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | +## All commands |
| 166 | +In the active path, just execute those bash-scripts: |
| 167 | + |
| 168 | +- `./runup.sh` |
| 169 | +- `./rundown.sh` |
| 170 | + |
| 171 | +**Bonus!** `./runctop.sh` is not a stack but a simple `docker run` to see the memory consumed by each container. |
| 172 | + |
0 commit comments