From 097ac45012cf89ecdbc18fc701b686d357694c88 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Fri, 29 Mar 2024 23:33:52 +0700 Subject: [PATCH] feat: update Dockerfile and gitlab-ci --- .gitlab-ci.yml | 22 ++++++++++------------ Dockerfile | 20 ++++++-------------- app/database/index.database.go | 1 + config/toml/config.toml | 8 ++++---- 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6cc09fd..2f142ec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,15 @@ stages: - - build-app - build-image - deploy -build-1: - stage: build-app - image: golang:alpine - script: - - go build -o main . - artifacts: - paths: - - main +#build-1: +# stage: build-app +# image: golang:alpine +# script: +# - go build -o main . +# artifacts: +# paths: +# - main build-2: stage: build-image @@ -19,8 +18,7 @@ build-2: - docker:dind script: - docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN registry.gitlab.com -# - docker build -t registry.gitlab.com/hanifsalafi/web-humas-be:dev . - - ddocker + - docker build -t registry.gitlab.com/hanifsalafi/web-humas-be:dev . - docker push registry.gitlab.com/hanifsalafi/web-humas-be:dev deploy: @@ -30,4 +28,4 @@ deploy: services: - docker:dind script: - - curl --user $JENKINS_USER:$JENKINS_PWD http://103.37.125.216:8080/job/deploy-humas-be/build?token=autodeployhumas \ No newline at end of file + - curl --user $JENKINS_USER:$JENKINS_PWD http://103.82.242.92:8080/job/autodeploy-humas-be/build?token=autodeployhumasbe \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 863a6ec..06753a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,13 @@ -FROM golang:alpine as builder +FROM golang:alpine -WORKDIR /src - -COPY go.* ./ +WORKDIR /app +COPY . . RUN go mod download RUN go get -v ./... RUN go mod vendor +RUN go build -o main . -COPY build . +EXPOSE 8800 -RUN apk update && apk add upx ca-certificates openssl && update-ca-certificates -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o /bin/api-binary ./main.go -RUN upx -9 /bin/api-binary - -FROM gcr.io/distroless/static:nonroot -WORKDIR /src/ -COPY --from=builder /bin/api-binary /bin/api-binary -COPY --from=builder --chown=nonroot /src/config /src/config -ENTRYPOINT ["/bin/api-binary"] \ No newline at end of file +CMD ["sh", "-c", "go run main.go"] \ No newline at end of file diff --git a/app/database/index.database.go b/app/database/index.database.go index 6db9707..403fd76 100644 --- a/app/database/index.database.go +++ b/app/database/index.database.go @@ -67,6 +67,7 @@ func (_db *Database) MigrateModels() { // Models list of models for migration func Models() []interface{} { return []interface{}{ + entity.Articles{}, entity.ArticleCategories{}, entity.ArticleCategoryDetails{}, entity.ArticleFiles{}, diff --git a/config/toml/config.toml b/config/toml/config.toml index 09dce99..138f6cf 100644 --- a/config/toml/config.toml +++ b/config/toml/config.toml @@ -9,7 +9,7 @@ production = false [db.postgres] dsn = "postgresql://humas_polri:P@ssw0rd.1@103.82.242.92:5432/humas_polri" # ://:@:/ -migrate = false +migrate = true seed = false [logger] @@ -19,9 +19,9 @@ level = 0 # panic -> 5, fatal -> 4, error -> 3, warn -> 2, info -> 1, debug -> 0 prettier = true [objectstorage.miniostorage] -endpoint = "103.37.125.216:9009" -access-key-id = "mnwWy87WrNiY4V7n63Nt" -secret-access-key = "OXG4Pzy5QaTJCbQmmA2aXt2jakxQVNfHA34kWzp5" +endpoint = "103.82.242.92:9001" +access-key-id = "A7USQd6iyinj38nDwnFE" +secret-access-key = "rTXDKRL8fhXUOaLDonwYThvDBPgNGPxvReTgfVGR" use-ssl = false bucket-name = "humas" location = "us-east-1"