From fe0412252babf959033a6e39ca5880c2273b3991 Mon Sep 17 00:00:00 2001 From: alimy Date: Wed, 8 Jun 2022 20:42:49 +0800 Subject: [PATCH] optimize #73 update docker compose support minio deploy --- config.yaml.sample | 12 +++++++----- docker-compose.yaml | 18 +++++++++++++++++- internal/dao/utils.go | 18 +++++++++--------- pkg/setting/settting.go | 2 ++ 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/config.yaml.sample b/config.yaml.sample index 68f1ed0b..4b66e9e8 100644 --- a/config.yaml.sample +++ b/config.yaml.sample @@ -12,8 +12,8 @@ Server: # 服务设置 ReadTimeout: 60 WriteTimeout: 60 Features: - Default: ["Alipay", "Zinc", "MySQL", "Redis", "AliOSS", "LoggerZinc"] - Develop: ["Sms", "Zinc", "MySQL", "MinIO", "LoggerFile"] + Default: ["Alipay", "Zinc", "MySQL", "Redis", "MinIO", "LoggerFile"] + Develop: ["Sms", "Zinc", "MySQL", "AliOSS", "LoggerZinc"] Slim: ["Zinc", "MySQL", "Redis", "MinIO", "LoggerFile"] Sms: "SmsJuhe" SmsJuhe: @@ -47,18 +47,20 @@ AliOSS: # 阿里云OSS存储配置 AccessKeySecret: Bucket: Domain: -MinIO: # MinIO OSS存储配置 +MinIO: # MinIO 存储配置 AccessKey: Q3AM3UQ867SPQQA43P2F SecretKey: zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG Secure: False - Endpoint: play.min.io + Endpoint: minio:9000 Bucket: paopao -S3: # S3 OSS存储配置 + Domain: 127.0.0.1:9000 +S3: # Amazon S3 存储配置 AccessKey: "YOUR-ACCESSKEYID" SecretKey: "YOUR-SECRETACCESSKEY" Secure: True Endpoint: s3.amazonaws.com Bucket: paopao + Domain: MySQL: # MySQL数据库 Username: paopao Password: paopao diff --git a/docker-compose.yaml b/docker-compose.yaml index 8751fc76..7a2387f9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -25,6 +25,21 @@ services: networks: - paopao-network + minio: + image: bitnami/minio:latest + restart: always + environment: + MINIO_ROOT_USER: minio-root-user + MINIO_ROOT_PASSWORD: minio-root-password + MINIO_DEFAULT_BUCKETS: paopao:public + ports: + - 127.0.0.1:9000:9000 + - 127.0.0.1:9001:9001 + volumes: + - ./data/minio/data:/data + networks: + - paopao-network + zinc: image: public.ecr.aws/prabhat/zinc:latest restart: always @@ -47,12 +62,13 @@ services: - db - redis - zinc + - minio # modify below to reflect your custom configure volumes: - ./config.yaml.sample:/app/paopao-ce/config.yaml - ./data/paopao-ce/data:/app/paopao-ce/data ports: - - 8008:8008 + - 127.0.0.1:8008:8008 networks: - paopao-network diff --git a/internal/dao/utils.go b/internal/dao/utils.go index 215cede8..e7d37f55 100644 --- a/internal/dao/utils.go +++ b/internal/dao/utils.go @@ -5,20 +5,20 @@ import ( ) func getOssDomain() string { + uri := "https://" if global.CfgIf("AliOSS") { - return "https://" + global.AliOSSSetting.Domain + "/" + return uri + global.AliOSSSetting.Domain + "/" } else if global.CfgIf("MinIO") { - domain := "http://" - if global.MinIOSetting.Secure { - domain = "http://" + if !global.MinIOSetting.Secure { + uri = "http://" } - return domain + global.MinIOSetting.Endpoint + "/" + global.MinIOSetting.Bucket + "/" + return uri + global.MinIOSetting.Domain + "/" + global.MinIOSetting.Bucket + "/" } else if global.CfgIf("S3") { - domain := "http://" - if global.S3Setting.Secure { - domain = "https://" + if !global.S3Setting.Secure { + uri = "http://" } - return domain + global.S3Setting.Endpoint + "/" + global.S3Setting.Bucket + "/" + // TODO: will not work well need test in real world + return uri + global.S3Setting.Domain + "/" + global.S3Setting.Bucket + "/" } return "" } diff --git a/pkg/setting/settting.go b/pkg/setting/settting.go index 7bffb0de..f880247e 100644 --- a/pkg/setting/settting.go +++ b/pkg/setting/settting.go @@ -87,6 +87,7 @@ type MinIOSettingS struct { Secure bool Endpoint string Bucket string + Domain string } type S3SettingS struct { @@ -95,6 +96,7 @@ type S3SettingS struct { Secure bool Endpoint string Bucket string + Domain string } type AliOSSSettingS struct {