-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yaml
93 lines (87 loc) · 2.47 KB
/
docker-compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
## Optional
# create a separated volume for docker image data
# mount volume to /docker-mnt directory
## Setup private docker registry
# mkdir -p /docker-mnt/auth
# mkdir -p /docker-mnt/data
# docker run --entrypoint htpasswd httpd:2 -Bbn <username> <password> > /docker-mnt/auth/htpasswd
# e.g. if you want to serve your private registry at registry.example.com
# SUBDOMAIN=<registry> URL=<exmaple.com> PUBLIC_IP=<X.X.X.X> STAGING=true docker compose up -d
version: "2.1"
services:
swag:
build:
context: ./nginx
args:
- SUBDOMAIN=${SUBDOMAIN}
- URL=${URL}
image: registry-nginx:v1.0
container_name: swag
cap_add:
- NET_ADMIN
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- URL=${URL}
- VALIDATION=http
- SUBDOMAINS=${SUBDOMAIN} #optional
#- CERTPROVIDER= #optional
#- DNSPLUGIN=cloudflare #optional
#- PROPAGATION= #optional
- [email protected] #optional
- ONLY_SUBDOMAINS=true #optional
#- EXTRA_DOMAINS= #optional
- STAGING=${STAGING} #optional
ports:
- 443:443
- 80:80 #optional
volumes:
- cert:/config/etc/letsencrypt:rw # swag would generate cert here
healthcheck:
test:
- CMD-SHELL
- bash
- -c
- |
cd /config/letsencrypt/live/${SUBDOMAIN}.${URL}/ &&
openssl verify -untrusted chain.pem cert.pem # STAGING=true would fail this check
interval: 5s
timeout: 60s
retries: 5
restart: unless-stopped
networks:
- main
registry:
restart: always
image: registry:2
container_name: registry
environment:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
REGISTRY_HTTP_TLS_CERTIFICATE: /cert/live/${SUBDOMAIN}.${URL}/fullchain.pem
REGISTRY_HTTP_TLS_KEY: /cert/live/${SUBDOMAIN}.${URL}/privkey.pem
REGISTRY_VALIDATION_DISABLED: 'true'
URL: ${URL}
SUBDOMAINS: ${SUBDOMAIN}
PUBLIC_IP: ${PUBLIC_IP}
depends_on:
swag:
condition: service_healthy
volumes:
- /docker-mnt/auth:/auth
- /docker-mnt/data:/data
# mount swag generated cert and reference by
# REGISTRY_HTTP_TLS_CERTIFICATE
# REGISTRY_HTTP_TLS_KEY
- cert:/cert:ro
networks:
- main
volumes:
cert:
name: registry-cert
driver: local
networks:
main: