feat: update Dockerfile and gitlab-ci
This commit is contained in:
parent
a7f1de3b4d
commit
590b45fc7c
|
|
@ -20,7 +20,7 @@ build-2:
|
||||||
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 .
|
||||||
- docker-compose build
|
- ddocker
|
||||||
- docker push registry.gitlab.com/hanifsalafi/web-humas-be:dev
|
- docker push registry.gitlab.com/hanifsalafi/web-humas-be:dev
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
FROM golang:alpine as builder
|
FROM golang:alpine as builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /src
|
||||||
|
|
||||||
COPY go.* ./
|
COPY go.* ./
|
||||||
|
|
||||||
RUN go get -v ../...
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
RUN go get -v ./...
|
||||||
RUN go mod vendor
|
RUN go mod vendor
|
||||||
|
|
||||||
COPY . .
|
COPY build .
|
||||||
|
|
||||||
RUN apk update && apk add upx ca-certificates openssl && update-ca-certificates
|
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 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o /bin/api-binary ./main.go
|
||||||
RUN upx -9 /bin/api-binary
|
RUN upx -9 /bin/api-binary
|
||||||
|
|
||||||
FROM gcr.io/distroless/static:nonroot
|
FROM gcr.io/distroless/static:nonroot
|
||||||
WORKDIR /app/
|
WORKDIR /src/
|
||||||
COPY --from=builder /bin/api-binary /bin/api-binary
|
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"]
|
ENTRYPOINT ["/bin/api-binary"]
|
||||||
|
|
@ -5,7 +5,7 @@ services:
|
||||||
image: registry.gitlab.com/hanifsalafi/web-humas-be:dev
|
image: registry.gitlab.com/hanifsalafi/web-humas-be:dev
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: build/Dockerfile
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
ports:
|
ports:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue