adding docker-compose file and add_user script
This commit is contained in:
commit
fff94a967a
21
docker-compose.yml
Normal file
21
docker-compose.yml
Normal file
@ -0,0 +1,21 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
registry:
|
||||
container_name: "docker-registry"
|
||||
image: registry:2
|
||||
|
||||
volumes:
|
||||
- ./data/reg_data:/var/lib/registry/
|
||||
- ./data/reg_auth:/auth
|
||||
|
||||
environment:
|
||||
- "REGISTRY_AUTH=htpasswd"
|
||||
- "REGISTRY_AUTH_HTPASSWD_REALM=Registry"
|
||||
- "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpassword"
|
||||
|
||||
ports:
|
||||
- 5000:5000
|
||||
|
||||
restart: always
|
||||
|
33
scripts/add_user.sh
Executable file
33
scripts/add_user.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#! /bin/bash
|
||||
USERNAME=$1
|
||||
SCRIPT_USER=$USER
|
||||
USER_HOME=$HOME
|
||||
|
||||
# Make sure a user is supplied
|
||||
if [[ -z "$USER" ]]; then
|
||||
echo "Username is required"
|
||||
echo "./add_user.sh <user>"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Get password inputs
|
||||
read -sp "Enter the account password: " PASS
|
||||
echo ""
|
||||
read -sp "Enter the password again: " PASS2
|
||||
echo ""
|
||||
|
||||
# Make sure passwords match
|
||||
if [ "$PASS" != "$PASS2" ]; then
|
||||
echo "Passwords do not match"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Make sure the auth folder exists
|
||||
mkdir -p ~/deployment/data/reg_auth
|
||||
|
||||
# Add the new user and password to the registry (using docker to avoid dependencies)
|
||||
# Then if docker doesn't crash, print a msg to stdout for the end user
|
||||
sudo docker run --rm \
|
||||
--entrypoint htpasswd \
|
||||
httpd:2 -Bbn $USERNAME $PASS >> $USER_HOME/deployment/data/reg_auth/htpassword && \
|
||||
echo "Made user $USERNAME"
|
Loading…
Reference in New Issue
Block a user