@@ -9,37 +9,42 @@ import (
99)
1010
1111const (
12- registryBinary = "/opt/drycc/registry/bin/registry"
13- registryConfig = "/etc/docker/registry/config.yml"
14- minioHostEnvVar = "DRYCC_MINIO_SERVICE_HOST"
15- minioPortEnvVar = "DRYCC_MINIO_SERVICE_PORT"
16- command = "serve"
12+ registryBinary = "/opt/drycc/registry/bin/registry"
13+ registryConfig = "/etc/docker/registry/config.yml"
14+ minioEndpointEnvVar = "DRYCC_MINIO_ENDPOINT"
15+ command = "serve"
1716)
1817
1918func main () {
2019 log .Println ("INFO: Starting registry..." )
21- mHost := os .Getenv (minioHostEnvVar )
22- mPort := os .Getenv (minioPortEnvVar )
20+ mEndpoint := os .Getenv (minioEndpointEnvVar )
2321 os .Setenv ("REGISTRY_STORAGE" , "s3" )
2422 os .Setenv ("REGISTRY_STORAGE_S3_BACKEND" , "minio" )
25- os .Setenv ("REGISTRY_STORAGE_S3_REGIONENDPOINT" , fmt .Sprintf ("http://%s:%s " , mHost , mPort ))
23+ os .Setenv ("REGISTRY_STORAGE_S3_REGIONENDPOINT" , fmt .Sprintf ("http://%s" , mEndpoint ))
2624
27- if accesskey , err := ioutil .ReadFile ("/var/run/secrets/drycc/objectstore /creds/accesskey" ); err != nil {
25+ if accesskey , err := ioutil .ReadFile ("/var/run/secrets/drycc/minio /creds/accesskey" ); err != nil {
2826 log .Fatal (err )
2927 } else {
3028 os .Setenv ("REGISTRY_STORAGE_S3_ACCESSKEY" , string (accesskey ))
3129 }
3230
33- if secretkey , err := ioutil .ReadFile ("/var/run/secrets/drycc/objectstore /creds/secretkey" ); err != nil {
31+ if secretkey , err := ioutil .ReadFile ("/var/run/secrets/drycc/minio /creds/secretkey" ); err != nil {
3432 log .Fatal (err )
3533 } else {
3634 os .Setenv ("REGISTRY_STORAGE_S3_SECRETKEY" , string (secretkey ))
3735 }
38- if bucket , err := ioutil .ReadFile ("/var/run/secrets/drycc/objectstore/creds/registry-bucket" ); err != nil {
39- log .Fatal (err )
36+
37+ bucketNameFile := "/var/run/secrets/drycc/minio/creds/registry-bucket"
38+ if _ , err := os .Stat (bucketNameFile ); os .IsNotExist (err ) {
39+ if bucket , err := ioutil .ReadFile (bucketNameFile ); err != nil {
40+ log .Fatal (err )
41+ } else {
42+ os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , string (bucket ))
43+ }
4044 } else {
41- os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , string ( bucket ))
45+ os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , "registry" ) // default bucket
4246 }
47+
4348 os .Setenv ("REGISTRY_STORAGE_S3_REGION" , "us-east-1" )
4449
4550 // run /bin/create_bucket
0 commit comments