diff --git a/build/docker/Dockerfile.glance b/build/docker/Dockerfile.glance index e7bbd73525..dc506fe9a5 100644 --- a/build/docker/Dockerfile.glance +++ b/build/docker/Dockerfile.glance @@ -2,5 +2,6 @@ FROM registry.cn-beijing.aliyuncs.com/yunionio/torrent:20210815.0 MAINTAINER "Zexi Li " +RUN apk add --no-cache s3fs-fuse --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing RUN mkdir -p /opt/yunion/bin ADD ./_output/alpine-build/bin/glance /opt/yunion/bin/glance diff --git a/pkg/image/drivers/s3/minio.go b/pkg/image/drivers/s3/minio.go index 84f00f83fa..76827d71e4 100644 --- a/pkg/image/drivers/s3/minio.go +++ b/pkg/image/drivers/s3/minio.go @@ -19,7 +19,6 @@ import ( "fmt" "io" "os" - "strings" "yunion.io/x/log" "yunion.io/x/pkg/errors" @@ -58,9 +57,6 @@ func Init(endpoint, accessKey, secretKey, bucket string, useSSL bool) error { if client != nil { return nil } - if !strings.HasPrefix(endpoint, "http://") && !strings.HasPrefix(endpoint, "https://") { - endpoint = "http://" + endpoint - } cfg := objectstore.NewObjectStoreClientConfig(endpoint, accessKey, secretKey) minioClient, err := objectstore.NewObjectStoreClient(cfg) if err != nil { diff --git a/pkg/image/service/service.go b/pkg/image/service/service.go index 9954521744..8ffdda05c3 100644 --- a/pkg/image/service/service.go +++ b/pkg/image/service/service.go @@ -18,6 +18,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "time" _ "github.com/go-sql-driver/mysql" @@ -135,8 +136,16 @@ func StartService() { } func initS3() { + url := options.Options.S3Endpoint + if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") { + prefix := "http://" + if options.Options.S3UseSSL { + prefix = "https://" + } + url = prefix + url + } err := s3.Init( - options.Options.S3Endpoint, + url, options.Options.S3AccessKey, options.Options.S3SecretKey, options.Options.S3BucketName, @@ -163,11 +172,6 @@ func initS3() { } } - prefix := "http://" - if options.Options.S3UseSSL { - prefix = "https://" - } - url := prefix + options.Options.S3Endpoint out, err := procutils.NewCommand("s3fs", options.Options.S3BucketName, options.Options.S3MountPoint, "-o", fmt.Sprintf("passwd_file=/tmp/s3-pass,use_path_request_style,url=%s", url)).Output()