Skip to content

Commit 89aff13

Browse files
committed
created first working version which fulfills all needs
1 parent 3571aad commit 89aff13

File tree

7 files changed

+72
-0
lines changed

7 files changed

+72
-0
lines changed

StartRegistry.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
#docker-compose -f docker-compose.yml up -d
3+
docker-compose build
4+
docker stack deploy -c docker-compose.yml registry

StopRegistry.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
#docker stack rm registry
3+
docker-compose -f docker-compose.yml down

docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "3.7"
2+
services:
3+
auth:
4+
build: ./nginx
5+
image: aussume_nginx_auth
6+
ports:
7+
- 5001:80
8+
links:
9+
- registry
10+
environment:
11+
USER: "<YourUserName>"
12+
PASS: "<YourPassword>"
13+
# depends_on:
14+
# - registry
15+
16+
registry:
17+
image: registry:latest
18+

nginx/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM nginx
2+
3+
RUN apt-get update -y \
4+
&& apt-get install -y \
5+
apache2-utils \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
ENV FORWARD_PORT=80
9+
10+
WORKDIR /opt
11+
12+
#RUN apk add --no-cache gettext
13+
14+
COPY auth.conf auth.htpasswd launch.sh ./
15+
16+
RUN chmod 0755 ./launch.sh
17+
18+
CMD ["./launch.sh"]

nginx/auth.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
listen *:80 default_server;
3+
return 444;
4+
}
5+
6+
server {
7+
listen *:80;
8+
server_name 127.0.0.1;
9+
10+
location / {
11+
satisfy any;
12+
allow all;
13+
14+
proxy_pass http://registry:5000;
15+
proxy_read_timeout 900;
16+
}
17+
}

nginx/auth.htpasswd

Whitespace-only changes.

nginx/launch.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
4+
envsubst < auth.conf > /etc/nginx/conf.d/auth.conf
5+
envsubst < auth.htpasswd > /etc/nginx/auth.htpasswd
6+
7+
htpasswd -c -b /etc/nginx/auth.htpasswd $USER $PASS
8+
9+
echo basic-auth-pwd
10+
cat /etc/nginx/auth.htpasswd
11+
12+
nginx -g "daemon off;"

0 commit comments

Comments
 (0)