#/bin/bash

# https://blog.csdn.net/weixin_43902588/article/details/142279993 参考文档

export QUAY=/var/lib/docker/quay

mkdir -p $QUAY/postgres
setfacl -m u:26:-wx $QUAY/postgres

docker run -d --name postgresql \
  --restart=always \
	-e POSTGRES_USER=user \
	-e POSTGRES_PASSWORD=pass \
	-e POSTGRES_DB=quay \
	-p 5432:5432 \
	-v $QUAY/postgres:/var/lib/postgresql/data:Z \
	postgres:10.12

docker exec -it postgresql /bin/bash -c 'echo "CREATE EXTENSION IF NOT EXISTS pg_trgm" | psql -d quay -U user'

docker inspect -f "{{.NetworkSettings.IPAddress}}" postgresql

# 不需要执行
docker run  -it --rm --name redis \
	-p 6379:6379 \
	redis:6.2.14 \
	redis-server --test-memory 4096



mkdir $QUAY/storage
mkdir $QUAY/config


docker run -d --name redis \
        -p 6379:6379 \
		-m 4g \
        redis:6.2.14 \
        --requirepass strongpassword

docker inspect -f "{{.NetworkSettings.IPAddress}}" redis

# 运行config服务 需要浏览器打开 http://172.31.2.7:8080/，并用 quayconfig/secret 登录。
docker run --rm -it --name quay_config -p 8080:8080 quay.io/projectquay/quay:3.11.1 config secret


setfacl -m u:1001:-wx $QUAY/storage
setfacl -m u:1001:-wx $QUAY/config

docker run -p 8033:8080 \
   --name=quay \
   --privileged=true \
   -v $QUAY/config:/conf/stack:Z \
   -v $QUAY/storage:/datastorage:Z \
   -d quay.io/projectquay/quay:3.11.1


# 登录dashboard 8033 创建账户和密码 创建项目
admin
V2ryStr@ngPss


docker login --tls-verify=false -u admin -p V2ryStr@ngPss 172.31.2.7:8033
docker login  -u admin -p V2ryStr@ngPss 172.31.2.7:8033

docker pull 172.31.2.7:8033/admin/cmii