Skip to content

Commit

Permalink
Add storage s3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
dyrnq committed Sep 5, 2024
1 parent ce17108 commit 5a9d7d5
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 16 deletions.
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,27 @@ envs description

0~15 because redis defaults to 16 databases, use `REDIS_DATABASES` env , eg. `--env REDIS_DATABASES=32`.

| name | description | default | required |
|----------------------|------------------|---------|----------|
| REG_NAME_ | name | | y |
| REG_PORT_ | port | | y |
| REG_PROXY_REMOTEURL_ | proxy remoteurl | | y |
| REG_PROXY_USERNAME_ | proxy username | | n |
| REG_PROXY_PASSWORD_ | proxy password | | n |
| REG_PROXY_TTL_ | proxy ttl | 168h | n |
| REG_REDIS_ADDR_ | redis addr | | y |
| REG_REDIS_PASSWORD_ | redis password | | n |
| REG_LOG_LEVEL_ | log level | info | n |
| REG_ENV_ | distribution env | | n |
| REDIS_DATABASES | redis databases | 16 | n |
| name | description | default | required |
|--------------------------------|-------------------|------------|----------|
| REG_NAME_ | name | | y |
| REG_PORT_ | port | | y |
| REG_PROXY_REMOTEURL_ | proxy remoteurl | | y |
| REG_PROXY_USERNAME_ | proxy username | | n |
| REG_PROXY_PASSWORD_ | proxy password | | n |
| REG_PROXY_TTL_ | proxy ttl | 168h | n |
| REG_REDIS_ADDR_ | redis addr | | y |
| REG_REDIS_PASSWORD_ | redis password | | n |
| REG_LOG_LEVEL_ | log level | info | n |
| REG_ENV_ | distribution env | | n |
| REG_STORAGE_ | storage | filesystem | y |
| REG_STORAGE_S3_ACCESSKEY_ | s3 accesskey | | y |
| REG_STORAGE_S3_SECRETKEY_ | s3 secretkey | | y |
| REG_STORAGE_S3_REGIONENDPOINT_ | s3 regionendpoint | | y |
| REG_STORAGE_S3_REGION_ | s3 region | us-east-1 | n |
| REG_STORAGE_S3_BUCKET_ | s3 bucket | | y |
| REG_STORAGE_S3_ROOTDIRECTORY_ | s3 rootdirectory | | n |
| REDIS_DATABASES | redis databases | 16 | n |


## mirrors

Expand Down
51 changes: 48 additions & 3 deletions rootfs/usr/local/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@ redis_password="REG_REDIS_PASSWORD_${1}"
redis_db="REG_REDIS_DB_${1}"
env="REG_ENV_${1}"

storage="REG_STORAGE_${1}"
storage_val=${!storage:-filesystem}

mkdir -p --verbose /etc/distribution/"${!name}"
rootdirectory="${DIST_HOME}"/registry/"${!name}"
mkdir -p --verbose "${rootdirectory}"
chown -R dist:dist "${rootdirectory}"
if [ "${storage_val,,}" = "filesystem" ]; then
rootdirectory="${DIST_HOME}"/registry/"${!name}"
mkdir -p --verbose "${rootdirectory}"
chown -R dist:dist "${rootdirectory}"
fi

s3_accesskey="REG_STORAGE_S3_ACCESSKEY_${1}"
s3_secretkey="REG_STORAGE_S3_SECRETKEY_${1}"
s3_region="REG_STORAGE_S3_REGION_${1}"
s3_regionendpoint="REG_STORAGE_S3_REGIONENDPOINT_${1}"
s3_bucket="REG_STORAGE_S3_BUCKET_${1}"
s3_rootdirectory="REG_STORAGE_S3_ROOTDIRECTORY_${1}"


cat >/etc/distribution/"${!name}"/config.yml<<EOF
# https://github.com/distribution/distribution
Expand All @@ -38,8 +51,40 @@ storage:
cache:
#blobdescriptor: inmemory
blobdescriptor: redis
EOF

if [ "${storage_val,,}" = "filesystem" ]; then
cat >>/etc/distribution/"${!name}"/config.yml<<EOF
filesystem:
rootdirectory: ${rootdirectory}
EOF
fi

if [ "${storage_val,,}" = "s3" ]; then
cat >>/etc/distribution/"${!name}"/config.yml<<EOF
s3:
accesskey: ${!s3_accesskey}
secretkey: ${!s3_secretkey}
region: ${!s3_region:-us-east-1}
regionendpoint: ${!s3_regionendpoint}
# forcepathstyle: true
# accelerate: false
bucket: ${!s3_bucket}
# encrypt: true
# keyid: mykeyid
# secure: true
# v4auth: true
# chunksize: 5242880
# multipartcopychunksize: 33554432
# multipartcopymaxconcurrency: 100
# multipartcopythresholdsize: 33554432
rootdirectory: ${!s3_rootdirectory}
usedualstack: false
# loglevel: debug
EOF
fi

cat >>/etc/distribution/"${!name}"/config.yml<<EOF
http:
addr: 0.0.0.0:${!port}
secret: asecretforlocaldevelopment
Expand Down

0 comments on commit 5a9d7d5

Please sign in to comment.