timeweb storage
This commit is contained in:
parent
9809e1f5cb
commit
ca8df5ef28
@ -3,6 +3,7 @@ WORKDIR /app
|
|||||||
COPY . .
|
COPY . .
|
||||||
ARG GITLAB_TOKEN
|
ARG GITLAB_TOKEN
|
||||||
ENV GOPRIVATE=penahub.gitlab.yandexcloud.net/backend/penahub_common
|
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 git config --global url."https://buildToken:glpat-axA8ttckx3aPf_xd2Dym@penahub.gitlab.yandexcloud.net/".insteadOf "https://penahub.gitlab.yandexcloud.net/"
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o stor ./main.go
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o stor ./main.go
|
||||||
|
50
dal/dal.go
50
dal/dal.go
@ -9,7 +9,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
bucketImages = "squizimages"
|
bucket = "3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b"
|
||||||
|
folderImages = "squizimages"
|
||||||
bucketFonts = "squizfonts"
|
bucketFonts = "squizfonts"
|
||||||
bucketScripts = "squizscript"
|
bucketScripts = "squizscript"
|
||||||
bucketStyle = "squizstyle"
|
bucketStyle = "squizstyle"
|
||||||
@ -20,37 +21,6 @@ type Storer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx context.Context, minioClient *minio.Client) (*Storer, error) {
|
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{
|
return &Storer{
|
||||||
client: minioClient,
|
client: minioClient,
|
||||||
@ -70,8 +40,8 @@ func (s *Storer) UploadImages(ctx context.Context, quid string, files map[string
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
_, err := s.client.PutObject(ctx,
|
_, err := s.client.PutObject(ctx,
|
||||||
bucketImages,
|
bucket,
|
||||||
fmt.Sprintf("%s/%s", quid, fname),
|
folderImages+"/"+fmt.Sprintf("%s/%s", quid, fname),
|
||||||
reader,
|
reader,
|
||||||
sizes[fname],
|
sizes[fname],
|
||||||
minio.PutObjectOptions{})
|
minio.PutObjectOptions{})
|
||||||
@ -100,8 +70,8 @@ func (s *Storer) UploadFonts(ctx context.Context, quid string, files map[string]
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if _, err := s.client.PutObject(ctx,
|
if _, err := s.client.PutObject(ctx,
|
||||||
bucketFonts,
|
bucket,
|
||||||
fmt.Sprintf("%s/%s", quid, fname),
|
bucketFonts + "/" +fmt.Sprintf("%s/%s", quid, fname),
|
||||||
reader,
|
reader,
|
||||||
sizes[fname],
|
sizes[fname],
|
||||||
minio.PutObjectOptions{}); err != nil {
|
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 {
|
func (s *Storer) UploadScript(ctx context.Context, quid string, file io.Reader, size int64) error {
|
||||||
if _, err := s.client.PutObject(ctx,
|
if _, err := s.client.PutObject(ctx,
|
||||||
bucketScripts,
|
bucket,
|
||||||
fmt.Sprintf("%s.js", quid),
|
bucketScripts + "/" + fmt.Sprintf("%s.js", quid),
|
||||||
file,
|
file,
|
||||||
size,
|
size,
|
||||||
minio.PutObjectOptions{}); err != nil {
|
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 {
|
func (s *Storer) UploadStyle(ctx context.Context, quid string, file io.Reader, size int64) error {
|
||||||
if _, err := s.client.PutObject(ctx,
|
if _, err := s.client.PutObject(ctx,
|
||||||
bucketStyle,
|
bucket,
|
||||||
fmt.Sprintf("%s.css", quid),
|
bucketStyle + "/" + fmt.Sprintf("%s.css", quid),
|
||||||
file,
|
file,
|
||||||
size,
|
size,
|
||||||
minio.PutObjectOptions{}); err != nil {
|
minio.PutObjectOptions{}); err != nil {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
version: "3"
|
||||||
services:
|
services:
|
||||||
storer:
|
storerv1.0.0:
|
||||||
hostname: squiz-storer
|
hostname: squiz-storerv1.0.0
|
||||||
container_name: squiz-storer
|
container_name: squiz-storerv1.0.0
|
||||||
image: $CI_REGISTRY_IMAGE/main-storer:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
image: $CI_REGISTRY_IMAGE/main-storer:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
||||||
tty: true
|
tty: true
|
||||||
environment:
|
environment:
|
||||||
@ -9,9 +10,9 @@ services:
|
|||||||
IS_PROD: 'false'
|
IS_PROD: 'false'
|
||||||
PUBLIC_ACCESS_SECRET_KEY: $JWT_PUBLIC_KEY
|
PUBLIC_ACCESS_SECRET_KEY: $JWT_PUBLIC_KEY
|
||||||
PORT: 1489
|
PORT: 1489
|
||||||
MINIO_EP: 'storage.yandexcloud.net'
|
MINIO_EP: s3.timeweb.cloud
|
||||||
MINIO_AK: 'YCAJEOcqqTHpiwL4qFwLfHPNA'
|
MINIO_AK: 5CV77KVDUU9H0II9R24M
|
||||||
MINIO_SK: 'YCNIAIat0XqdDzycWsYKX3OU7mPor6S0WmMoG4Ry'
|
MINIO_SK: 0W0m8DyvdAKRJnsAy6mB5zndQ7RouJBLhqhtThcu
|
||||||
PG_CRED: 'host=10.8.0.9 port=5433 user=squiz password=Redalert2 dbname=squiz sslmode=disable'
|
PG_CRED: 'host=10.8.0.9 port=5433 user=squiz password=Redalert2 dbname=squiz sslmode=disable'
|
||||||
ports:
|
ports:
|
||||||
- 10.8.0.9:1489:1489
|
- 10.8.0.9:1589:1489
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
storer:
|
storerv1.0.0:
|
||||||
hostname: squiz-storer
|
hostname: squiz-storerv1.0.0
|
||||||
container_name: squiz-storer
|
container_name: squiz-storerv1.0.0
|
||||||
image: $CI_REGISTRY_IMAGE/staging-storer:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
image: $CI_REGISTRY_IMAGE/staging-storer:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
||||||
tty: true
|
tty: true
|
||||||
environment:
|
environment:
|
||||||
@ -9,9 +9,9 @@ services:
|
|||||||
IS_PROD: 'false'
|
IS_PROD: 'false'
|
||||||
PUBLIC_ACCESS_SECRET_KEY: $JWT_PUBLIC_KEY
|
PUBLIC_ACCESS_SECRET_KEY: $JWT_PUBLIC_KEY
|
||||||
PORT: 1489
|
PORT: 1489
|
||||||
MINIO_EP: 'storage.yandexcloud.net'
|
MINIO_EP: s3.timeweb.cloud
|
||||||
MINIO_AK: 'YCAJEOcqqTHpiwL4qFwLfHPNA'
|
MINIO_AK: 5CV77KVDUU9H0II9R24M
|
||||||
MINIO_SK: 'YCNIAIat0XqdDzycWsYKX3OU7mPor6S0WmMoG4Ry'
|
MINIO_SK: 0W0m8DyvdAKRJnsAy6mB5zndQ7RouJBLhqhtThcu
|
||||||
PG_CRED: 'host=10.8.0.5 port=5433 user=squiz password=Redalert2 dbname=squiz sslmode=disable'
|
PG_CRED: 'host=10.8.0.5 port=5433 user=squiz password=Redalert2 dbname=squiz sslmode=disable'
|
||||||
ports:
|
ports:
|
||||||
- 10.8.0.5:1489:1489
|
- 10.8.0.5:1589:1489
|
||||||
|
Loading…
Reference in New Issue
Block a user