From 6f0b3af38d52cd588b768e5c76048784b62fb739 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Thu, 7 Mar 2024 17:20:51 +0700 Subject: [PATCH] feat: update Dockerfile and gitlab-ci --- .gitlab-ci.yml | 2 +- build/Dockerfile => Dockerfile | 10 +++++----- docker-compose.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename build/Dockerfile => Dockerfile (71%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 987b975..6cc09fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ build-2: script: - docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN registry.gitlab.com # - docker build -t registry.gitlab.com/hanifsalafi/web-humas-be:dev . - - docker-compose build + - ddocker - docker push registry.gitlab.com/hanifsalafi/web-humas-be:dev deploy: diff --git a/build/Dockerfile b/Dockerfile similarity index 71% rename from build/Dockerfile rename to Dockerfile index 99bba1c..863a6ec 100644 --- a/build/Dockerfile +++ b/Dockerfile @@ -1,21 +1,21 @@ FROM golang:alpine as builder -WORKDIR /app +WORKDIR /src COPY go.* ./ -RUN go get -v ../... RUN go mod download +RUN go get -v ./... RUN go mod vendor -COPY . . +COPY build . 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 /app/ +WORKDIR /src/ COPY --from=builder /bin/api-binary /bin/api-binary -COPY --from=builder --chown=nonroot /app/config /app/config +COPY --from=builder --chown=nonroot /src/config /src/config ENTRYPOINT ["/bin/api-binary"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6bd2843..fa005ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: image: registry.gitlab.com/hanifsalafi/web-humas-be:dev build: context: . - dockerfile: build/Dockerfile + dockerfile: Dockerfile volumes: - .:/app ports: