feat: update Dockerfile and gitlab-ci
This commit is contained in:
parent
590b45fc7c
commit
097ac45012
|
|
@ -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
|
||||
- curl --user $JENKINS_USER:$JENKINS_PWD http://103.82.242.92:8080/job/autodeploy-humas-be/build?token=autodeployhumasbe
|
||||
20
Dockerfile
20
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"]
|
||||
CMD ["sh", "-c", "go run main.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{},
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ production = false
|
|||
|
||||
[db.postgres]
|
||||
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
|
||||
|
||||
[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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue