diff --git a/Dockerfile b/Dockerfile index 7be6e0f..94647b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ WORKDIR /app COPY . . ARG GITLAB_TOKEN ENV GOPRIVATE=penahub.gitlab.yandexcloud.net/backend/penahub_common +RUN apk add git RUN git config --global url."https://buildToken:glpat-axA8ttckx3aPf_xd2Dym@penahub.gitlab.yandexcloud.net/".insteadOf "https://penahub.gitlab.yandexcloud.net/" RUN go mod download RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o stor ./main.go diff --git a/dal/dal.go b/dal/dal.go index b46ac5d..fd375d3 100644 --- a/dal/dal.go +++ b/dal/dal.go @@ -9,7 +9,8 @@ import ( ) const ( - bucketImages = "squizimages" + bucket = "3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b" + folderImages = "squizimages" bucketFonts = "squizfonts" bucketScripts = "squizscript" bucketStyle = "squizstyle" @@ -20,37 +21,6 @@ type Storer struct { } func New(ctx context.Context, minioClient *minio.Client) (*Storer, error) { - if ok, err := minioClient.BucketExists(ctx, bucketImages); !ok { - if err := minioClient.MakeBucket(ctx, bucketImages, minio.MakeBucketOptions{}); err != nil { - return nil, err - } - } else if err != nil { - return nil, err - } - - if ok, err := minioClient.BucketExists(ctx, bucketFonts); !ok { - if err := minioClient.MakeBucket(ctx, bucketFonts, minio.MakeBucketOptions{}); err != nil { - return nil, err - } - } else if err != nil { - return nil, err - } - - if ok, err := minioClient.BucketExists(ctx, bucketScripts); !ok { - if err := minioClient.MakeBucket(ctx, bucketScripts, minio.MakeBucketOptions{}); err != nil { - return nil, err - } - } else if err != nil { - return nil, err - } - - if ok, err := minioClient.BucketExists(ctx, bucketStyle); !ok { - if err := minioClient.MakeBucket(ctx, bucketStyle, minio.MakeBucketOptions{}); err != nil { - return nil, err - } - } else if err != nil { - return nil, err - } return &Storer{ client: minioClient, @@ -70,8 +40,8 @@ func (s *Storer) UploadImages(ctx context.Context, quid string, files map[string go func() { defer wg.Done() _, err := s.client.PutObject(ctx, - bucketImages, - fmt.Sprintf("%s/%s", quid, fname), + bucket, + folderImages+"/"+fmt.Sprintf("%s/%s", quid, fname), reader, sizes[fname], minio.PutObjectOptions{}) @@ -100,8 +70,8 @@ func (s *Storer) UploadFonts(ctx context.Context, quid string, files map[string] go func() { defer wg.Done() if _, err := s.client.PutObject(ctx, - bucketFonts, - fmt.Sprintf("%s/%s", quid, fname), + bucket, + bucketFonts + "/" +fmt.Sprintf("%s/%s", quid, fname), reader, sizes[fname], minio.PutObjectOptions{}); err != nil { @@ -119,8 +89,8 @@ func (s *Storer) UploadFonts(ctx context.Context, quid string, files map[string] func (s *Storer) UploadScript(ctx context.Context, quid string, file io.Reader, size int64) error { if _, err := s.client.PutObject(ctx, - bucketScripts, - fmt.Sprintf("%s.js", quid), + bucket, + bucketScripts + "/" + fmt.Sprintf("%s.js", quid), file, size, minio.PutObjectOptions{}); err != nil { @@ -132,8 +102,8 @@ func (s *Storer) UploadScript(ctx context.Context, quid string, file io.Reader, func (s *Storer) UploadStyle(ctx context.Context, quid string, file io.Reader, size int64) error { if _, err := s.client.PutObject(ctx, - bucketStyle, - fmt.Sprintf("%s.css", quid), + bucket, + bucketStyle + "/" + fmt.Sprintf("%s.css", quid), file, size, minio.PutObjectOptions{}); err != nil { diff --git a/deployments/main/docker-compose.yaml b/deployments/main/docker-compose.yaml index 2fb9352..79491c5 100644 --- a/deployments/main/docker-compose.yaml +++ b/deployments/main/docker-compose.yaml @@ -1,7 +1,8 @@ +version: "3" services: - storer: - hostname: squiz-storer - container_name: squiz-storer + storerv1.0.0: + hostname: squiz-storerv1.0.0 + container_name: squiz-storerv1.0.0 image: $CI_REGISTRY_IMAGE/main-storer:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID tty: true environment: @@ -9,9 +10,9 @@ services: IS_PROD: 'false' PUBLIC_ACCESS_SECRET_KEY: $JWT_PUBLIC_KEY PORT: 1489 - MINIO_EP: 'storage.yandexcloud.net' - MINIO_AK: 'YCAJEOcqqTHpiwL4qFwLfHPNA' - MINIO_SK: 'YCNIAIat0XqdDzycWsYKX3OU7mPor6S0WmMoG4Ry' + MINIO_EP: s3.timeweb.cloud + MINIO_AK: 5CV77KVDUU9H0II9R24M + MINIO_SK: 0W0m8DyvdAKRJnsAy6mB5zndQ7RouJBLhqhtThcu PG_CRED: 'host=10.8.0.9 port=5433 user=squiz password=Redalert2 dbname=squiz sslmode=disable' ports: - - 10.8.0.9:1489:1489 + - 10.8.0.9:1589:1489 diff --git a/deployments/staging/docker-compose.yaml b/deployments/staging/docker-compose.yaml index 12bb4dd..b83b494 100644 --- a/deployments/staging/docker-compose.yaml +++ b/deployments/staging/docker-compose.yaml @@ -1,7 +1,7 @@ services: - storer: - hostname: squiz-storer - container_name: squiz-storer + storerv1.0.0: + hostname: squiz-storerv1.0.0 + container_name: squiz-storerv1.0.0 image: $CI_REGISTRY_IMAGE/staging-storer:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID tty: true environment: @@ -9,9 +9,9 @@ services: IS_PROD: 'false' PUBLIC_ACCESS_SECRET_KEY: $JWT_PUBLIC_KEY PORT: 1489 - MINIO_EP: 'storage.yandexcloud.net' - MINIO_AK: 'YCAJEOcqqTHpiwL4qFwLfHPNA' - MINIO_SK: 'YCNIAIat0XqdDzycWsYKX3OU7mPor6S0WmMoG4Ry' + MINIO_EP: s3.timeweb.cloud + MINIO_AK: 5CV77KVDUU9H0II9R24M + MINIO_SK: 0W0m8DyvdAKRJnsAy6mB5zndQ7RouJBLhqhtThcu PG_CRED: 'host=10.8.0.5 port=5433 user=squiz password=Redalert2 dbname=squiz sslmode=disable' ports: - - 10.8.0.5:1489:1489 + - 10.8.0.5:1589:1489