Version 0.2
Changes: - rename project to remote gitlab - changes envs in internal\config\config.go - added deployments\staging\docker-compose.yaml - added Dockerfile - added staging.env
This commit is contained in:
parent
7d677a2d83
commit
77b57819db
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.idea
|
||||
test.env
|
55
.gitlab-ci.yml
Normal file
55
.gitlab-ci.yml
Normal file
@ -0,0 +1,55 @@
|
||||
include:
|
||||
- project: "devops/pena-continuous-integration"
|
||||
file: "/templates/docker/build-template.gitlab-ci.yml"
|
||||
- project: "devops/pena-continuous-integration"
|
||||
file: "/templates/docker/clean-template.gitlab-ci.yml"
|
||||
- project: "devops/pena-continuous-integration"
|
||||
file: "/templates/docker/deploy-template.gitlab-ci.yml"
|
||||
stages:
|
||||
- clean
|
||||
- build
|
||||
- deploy
|
||||
|
||||
clear-old-images:
|
||||
extends: .clean_template
|
||||
variables:
|
||||
STAGING_BRANCH: "main"
|
||||
PRODUCTION_BRANCH: "main"
|
||||
image:
|
||||
name: docker/compose:1.28.0
|
||||
entrypoint: [""]
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- docker images
|
||||
script:
|
||||
- docker system prune -af
|
||||
|
||||
build-app:
|
||||
stage: build
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- echo STAGING_BRANCH = $STAGING_BRANCH
|
||||
- echo CI_REGISTRY = $CI_REGISTRY
|
||||
- echo CI_REGISTRY_USER = $CI_REGISTRY_USER
|
||||
- echo CI_PROJECT_DIR = $CI_PROJECT_DIR
|
||||
- echo CI_REGISTRY_IMAGE = $CI_REGISTRY_IMAGE
|
||||
- echo CI_COMMIT_REF_SLUG = $CI_COMMIT_REF_SLUG
|
||||
- echo DOCKER_BUILD_PATH = $DOCKER_BUILD_PATH
|
||||
- echo CI_PIPELINE_ID = $CI_PIPELINE_ID
|
||||
variables:
|
||||
DOCKER_BUILD_PATH: "build/Dockerfile"
|
||||
PRODUCTION_BRANCH: main
|
||||
STAGING_BRANCH: "main"
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $PRODUCTION_BRANCH || $CI_COMMIT_BRANCH == $STAGING_BRANCH
|
||||
|
||||
script:
|
||||
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID --build-arg GITLAB_TOKEN=$GITLAB_TOKEN $CI_PROJECT_DIR
|
||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
||||
|
||||
|
||||
deploy-to-staging:
|
||||
extends: .deploy_template
|
||||
variables:
|
||||
DEPLOY_TO: "staging"
|
||||
BRANCH: "main"
|
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
||||
FROM golang:alpine as build
|
||||
WORKDIR /app
|
||||
ARG GITLAB_TOKEN
|
||||
RUN apk add git
|
||||
ENV GOPRIVATE=penahub.gitlab.yandexcloud.net/backend/penahub_common
|
||||
RUN git config --global url."https://forgomod:${GITLAB_TOKEN}@penahub.gitlab.yandexcloud.net/".insteadOf "https://penahub.gitlab.yandexcloud.net/"
|
||||
COPY . .
|
||||
RUN go mod download
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app ./cmd/verification/main.go
|
||||
|
||||
FROM alpine
|
||||
EXPOSE 80
|
||||
COPY --from=build app/app .
|
||||
COPY --from=build app/staging.env .
|
||||
ENV DOMAIN=tempgen.pena.digital
|
||||
ENV YADISK_CLIENT_ID=1ed4b85c1a5c4e6abf783d3ea28fd947
|
||||
ENV YADISK_CLIENT_SECRET=e1d4f385c1274dccb7d29646b802d607
|
||||
RUN apk add --no-cache ca-certificates
|
||||
CMD ["/app"]
|
@ -2,8 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"verification/internal/app"
|
||||
"verification/internal/config"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/app"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
17
deployments/staging/docker-compose.yaml
Normal file
17
deployments/staging/docker-compose.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
services:
|
||||
verification:
|
||||
container_name: verification_service
|
||||
restart: unless-stopped
|
||||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
||||
hostname: verification_service
|
||||
ports:
|
||||
- "7035:7035"
|
||||
environment:
|
||||
MONGO_URI: mongodb://$MONGO_USER:$MONGO_PASSWORD@10.6.0.11:27017/?authSource=verification
|
||||
PENADISK_URL: $PENADISK_URL
|
||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
|
||||
TELEGRAM_CHANNEL_ID: $TELEGRAM_CHANNEL_ID
|
||||
S3_ENDPOINT: $S3_ENDPOINT
|
||||
S3_ACCESS_KEY_ID: $S3_ACCESS_KEY_ID
|
||||
S3_SECRET_KEY: $S3_SECRET_KEY
|
||||
tty: true
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
||||
module verification
|
||||
module penahub.gitlab.yandexcloud.net/backend/verification
|
||||
|
||||
go 1.19
|
||||
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"verification/internal/client"
|
||||
"verification/internal/config"
|
||||
"verification/internal/initialize"
|
||||
"verification/internal/server"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/client"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/config"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/initialize"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/server"
|
||||
)
|
||||
|
||||
func Run(cfg *config.Config) {
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"os"
|
||||
"os/signal"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/server"
|
||||
"syscall"
|
||||
"verification/internal/server"
|
||||
)
|
||||
|
||||
func gracefulShutdown(ctx context.Context, logger *zap.Logger, httpSrv *server.HTTP, mongoClient *mongo.Client) {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"go.uber.org/zap"
|
||||
"verification/internal/models"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/models"
|
||||
)
|
||||
|
||||
type Customer struct {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"bytes"
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"go.uber.org/zap"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/models"
|
||||
"text/template"
|
||||
"verification/internal/models"
|
||||
)
|
||||
|
||||
type Telegram struct {
|
||||
|
@ -11,9 +11,9 @@ type Config struct {
|
||||
HttpAddress string `env:"HTTP_ADDRESS" envDefault:":80"`
|
||||
MongoUri string `env:"MONGO_URI,required"`
|
||||
DatabaseName string `env:"MONGO_DATABASE_NAME,required"`
|
||||
S3Endpoint string `env:"S3_ENDPOINT"`
|
||||
S3AccessKeyID string `env:"S3_ACCESS_KEY_ID"`
|
||||
S3SecretKey string `env:"S3_SECRET_KEY"`
|
||||
S3Endpoint string `env:"S3_ENDPOINT,required"`
|
||||
S3AccessKeyID string `env:"S3_ACCESS_KEY_ID,required"`
|
||||
S3SecretKey string `env:"S3_SECRET_KEY,required"`
|
||||
CustomerSvcAddress string `env:"CUSTOMER_SVC_ADDRESS,required"`
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@ package controllers
|
||||
import (
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/models"
|
||||
"reflect"
|
||||
"verification/internal/models"
|
||||
)
|
||||
|
||||
var validate = validator.New()
|
||||
|
@ -3,9 +3,9 @@ package controllers
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"mime/multipart"
|
||||
"verification/internal/client"
|
||||
"verification/internal/models"
|
||||
"verification/internal/repository"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/client"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/models"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/repository"
|
||||
)
|
||||
|
||||
type VerificationController struct {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/client"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/controllers"
|
||||
"reflect"
|
||||
"verification/internal/client"
|
||||
"verification/internal/controllers"
|
||||
)
|
||||
|
||||
type Controller interface {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"github.com/minio/minio-go/v7"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.uber.org/zap"
|
||||
"verification/internal/repository"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/repository"
|
||||
)
|
||||
|
||||
type Repositories struct {
|
||||
|
@ -13,8 +13,8 @@ import (
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"go.uber.org/zap"
|
||||
"mime/multipart"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/models"
|
||||
"time"
|
||||
"verification/internal/models"
|
||||
)
|
||||
|
||||
type VerificationRepository struct {
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
"go.uber.org/zap"
|
||||
"verification/internal/config"
|
||||
"verification/internal/initialize"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/config"
|
||||
"penahub.gitlab.yandexcloud.net/backend/verification/internal/initialize"
|
||||
)
|
||||
|
||||
type HTTP struct {
|
||||
|
3
staging.env
Normal file
3
staging.env
Normal file
@ -0,0 +1,3 @@
|
||||
MONGO_DATABASE_NAME=verification
|
||||
HTTP_ADDRESS=:7035
|
||||
CUSTOMER_SVC_ADDRESS=https://admin.pena.digital/customer
|
Loading…
Reference in New Issue
Block a user