Compare commits
2 Commits
522b2ddf8b
...
bf361bd587
| Author | SHA1 | Date | |
|---|---|---|---|
| bf361bd587 | |||
| f3b17e69ff |
5
.env.sample
Normal file
5
.env.sample
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
TAG=
|
||||||
|
APIPORT=
|
||||||
|
BASEDIR=
|
||||||
|
EXTRANET=
|
||||||
|
INTRANET=
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
files/
|
||||||
|
.env
|
||||||
46
README.md
46
README.md
@@ -1,2 +1,46 @@
|
|||||||
# compose-caddy
|
# Basic Caddy docker-compose config
|
||||||
|
* can be run on single node setup or in swarm
|
||||||
|
* recommend to set `replicas` on 2 or more if deploy in swarm
|
||||||
|
|
||||||
|
## howto
|
||||||
|
### single node
|
||||||
|
#### start container
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
#### stop container (and remove)
|
||||||
|
```bash
|
||||||
|
docker compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
#### view logs
|
||||||
|
```bash
|
||||||
|
docker compose logs -f
|
||||||
|
```
|
||||||
|
|
||||||
|
#### reload config
|
||||||
|
```bash
|
||||||
|
docker compose restart
|
||||||
|
```
|
||||||
|
|
||||||
|
### swarm
|
||||||
|
#### start aka deploy
|
||||||
|
```bash
|
||||||
|
docker stack deploy -c docker-compose.yml caddy
|
||||||
|
```
|
||||||
|
|
||||||
|
#### stop container aka service
|
||||||
|
```bash
|
||||||
|
docker service rm caddy_caddy
|
||||||
|
```
|
||||||
|
|
||||||
|
#### view logs
|
||||||
|
```bash
|
||||||
|
docker service logs caddy_caddy -f
|
||||||
|
```
|
||||||
|
|
||||||
|
#### reload config (no downtime if replica 2 or more)
|
||||||
|
```bash
|
||||||
|
docker service update caddy_caddy --force
|
||||||
|
```
|
||||||
34
docker-compose.yml
Normal file
34
docker-compose.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# https://docs.docker.com/compose/compose-file/compose-file-v3/
|
||||||
|
---
|
||||||
|
version: "3.9"
|
||||||
|
services:
|
||||||
|
caddy:
|
||||||
|
image: caddy:${TAG:-alpine}
|
||||||
|
container_name: caddy
|
||||||
|
env_file: .env
|
||||||
|
restart: unless-stopped
|
||||||
|
deploy:
|
||||||
|
replicas: 1 # in swarm set min 2
|
||||||
|
placement:
|
||||||
|
max_replicas_per_node: 1
|
||||||
|
update_config:
|
||||||
|
parallelism: 1
|
||||||
|
delay: 10s
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
- ${APIPORT:-2019}:2019
|
||||||
|
volumes:
|
||||||
|
- ${BASEDIR:-./files}/conf:/etc/caddy/
|
||||||
|
- ${BASEDIR:-./files}/data/:/data
|
||||||
|
networks:
|
||||||
|
- frontend
|
||||||
|
- backend
|
||||||
|
|
||||||
|
networks:
|
||||||
|
frontend:
|
||||||
|
name: ${EXTRANET:-frontend}
|
||||||
|
external: true
|
||||||
|
backend:
|
||||||
|
name: ${INTRANET:-backend}
|
||||||
|
external: true
|
||||||
2
files/conf/Caddyfile
Normal file
2
files/conf/Caddyfile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import snippets/*
|
||||||
|
import pages/*
|
||||||
4
files/conf/pages/example.com
Normal file
4
files/conf/pages/example.com
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
http://example.com {
|
||||||
|
import auth "*"
|
||||||
|
respond "example.com here!"
|
||||||
|
}
|
||||||
12
files/conf/snippets/auth
Normal file
12
files/conf/snippets/auth
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
## generate pass hash (debian):
|
||||||
|
# sudo apt install apache2-utils
|
||||||
|
# htpasswd -bnBC 10 "" password | tr -d ':'
|
||||||
|
|
||||||
|
# user: test
|
||||||
|
# password: password
|
||||||
|
|
||||||
|
(auth) {
|
||||||
|
basicauth {args.0} {
|
||||||
|
test $2y$10$XSrHHXUlQZeRumAc9nl7QevDzKv9H5TXVtb6nxr0Gmrk6VogHWRVK
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user