-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.bash
More file actions
executable file
·52 lines (44 loc) · 1.48 KB
/
docker.bash
File metadata and controls
executable file
·52 lines (44 loc) · 1.48 KB
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
#!/bin/bash
export $(egrep -v '^#' .env | xargs)
case $1 in
start)
docker run --rm \
-p 127.0.0.1:$REGISTRY_PORT:443 \
--name registry \
-v $(pwd)/storage:/var/lib/registry \
-v "$(pwd)"/auth:/auth \
-e REGISTRY_LOG_LEVEL=debug \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_HTTP_SECRET='$REGISTRY_HTTP_SECRET'" \
-e "REGISTRY_AUTH_HTPASSWD_REALM='Registry Realm'" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
-v "$(pwd)"/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/docker.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/docker.key \
registry:2
;;
stop)
docker kill registry || true
;;
update-certs)
cp /etc/letsencrypt/live/$REGISTRY_SSL_FOLDER/fullchain.pem certs/docker.crt
cp /etc/letsencrypt/live/$REGISTRY_SSL_FOLDER/privkey.pem certs/docker.key
;;
update-password)
read -p "Registry user: " USERNAME
read -s -p "New password: " PASSWORD
docker run --rm -it appsoa/docker-alpine-htpasswd "$USERNAME" "$PASSWORD" > auth/htpasswd
;;
install)
rm /usr/local/bin/docker-registry
ln -s $(pwd)/docker.bash /usr/local/bin/docker-registry
chmod +x /usr/local/bin/docker-registry
cp docker-registry.service /etc/systemd/system/docker-registry.service
echo 'WorkingDirectory='$PWD >> /etc/systemd/system/docker-registry.service
;;
*)
echo Usage:
echo " bash docker.bask <start | stop | update-certs | update-password | install>"
;;
esac