feat: update Dockerfile and gitlab-ci

This commit is contained in:
hanif salafi 2024-03-29 23:33:52 +07:00
parent 590b45fc7c
commit 097ac45012
4 changed files with 21 additions and 30 deletions

View File

@ -1,16 +1,15 @@
stages: stages:
- build-app
- build-image - build-image
- deploy - deploy
build-1: #build-1:
stage: build-app # stage: build-app
image: golang:alpine # image: golang:alpine
script: # script:
- go build -o main . # - go build -o main .
artifacts: # artifacts:
paths: # paths:
- main # - main
build-2: build-2:
stage: build-image stage: build-image
@ -19,8 +18,7 @@ build-2:
- docker:dind - docker:dind
script: script:
- docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN registry.gitlab.com - docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN registry.gitlab.com
# - docker build -t registry.gitlab.com/hanifsalafi/web-humas-be:dev . - docker build -t registry.gitlab.com/hanifsalafi/web-humas-be:dev .
- ddocker
- docker push registry.gitlab.com/hanifsalafi/web-humas-be:dev - docker push registry.gitlab.com/hanifsalafi/web-humas-be:dev
deploy: deploy:
@ -30,4 +28,4 @@ deploy:
services: services:
- docker:dind - docker:dind
script: script:
- curl --user $JENKINS_USER:$JENKINS_PWD http://103.37.125.216:8080/job/deploy-humas-be/build?token=autodeployhumas - curl --user $JENKINS_USER:$JENKINS_PWD http://103.82.242.92:8080/job/autodeploy-humas-be/build?token=autodeployhumasbe

View File

@ -1,21 +1,13 @@
FROM golang:alpine as builder FROM golang:alpine
WORKDIR /src WORKDIR /app
COPY . .
COPY go.* ./
RUN go mod download RUN go mod download
RUN go get -v ./... RUN go get -v ./...
RUN go mod vendor 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 CMD ["sh", "-c", "go run main.go"]
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"]

View File

@ -67,6 +67,7 @@ func (_db *Database) MigrateModels() {
// Models list of models for migration // Models list of models for migration
func Models() []interface{} { func Models() []interface{} {
return []interface{}{ return []interface{}{
entity.Articles{},
entity.ArticleCategories{}, entity.ArticleCategories{},
entity.ArticleCategoryDetails{}, entity.ArticleCategoryDetails{},
entity.ArticleFiles{}, entity.ArticleFiles{},

View File

@ -9,7 +9,7 @@ production = false
[db.postgres] [db.postgres]
dsn = "postgresql://humas_polri:P@ssw0rd.1@103.82.242.92:5432/humas_polri" # <driver>://<username>:<password>@<host>:<port>/<database> dsn = "postgresql://humas_polri:P@ssw0rd.1@103.82.242.92:5432/humas_polri" # <driver>://<username>:<password>@<host>:<port>/<database>
migrate = false migrate = true
seed = false seed = false
[logger] [logger]
@ -19,9 +19,9 @@ level = 0 # panic -> 5, fatal -> 4, error -> 3, warn -> 2, info -> 1, debug -> 0
prettier = true prettier = true
[objectstorage.miniostorage] [objectstorage.miniostorage]
endpoint = "103.37.125.216:9009" endpoint = "103.82.242.92:9001"
access-key-id = "mnwWy87WrNiY4V7n63Nt" access-key-id = "A7USQd6iyinj38nDwnFE"
secret-access-key = "OXG4Pzy5QaTJCbQmmA2aXt2jakxQVNfHA34kWzp5" secret-access-key = "rTXDKRL8fhXUOaLDonwYThvDBPgNGPxvReTgfVGR"
use-ssl = false use-ssl = false
bucket-name = "humas" bucket-name = "humas"
location = "us-east-1" location = "us-east-1"