From 88782ae4e0d789bdbea5044bb23b17c201d2e266 Mon Sep 17 00:00:00 2001 From: Azis Alvriyanto Date: Wed, 18 Dec 2024 23:50:54 +0700 Subject: [PATCH] build(deployments): update dockerfile to use scratch image --- deployments/Dockerfile | 29 ++++------------------------- deployments/goreleaser.yml | 1 - 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/deployments/Dockerfile b/deployments/Dockerfile index dccf0f2..86c1053 100644 --- a/deployments/Dockerfile +++ b/deployments/Dockerfile @@ -1,25 +1,4 @@ -FROM golang:1.23-alpine AS builder - -WORKDIR /app - -# copy and download all necessary modules -COPY go.mod . -COPY go.sum . - -RUN go mod download - -# copy all local files to Image -COPY . . - -# build Docker Image with CGO Enabled -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o go-qris ./cmd - -FROM alpine:latest - -WORKDIR /app - -# get Executable Binary file to new Image -COPY --from=builder /app/go-qris ./ - -# run the server executable -CMD ["./go-qris"] +FROM scratch +COPY go-qris /go-qris +EXPOSE 1337 +ENTRYPOINT ["/go-qris","run"] \ No newline at end of file diff --git a/deployments/goreleaser.yml b/deployments/goreleaser.yml index f408d9c..f24aae0 100644 --- a/deployments/goreleaser.yml +++ b/deployments/goreleaser.yml @@ -39,7 +39,6 @@ dockers: dockerfile: ./deployments/Dockerfile build_flag_templates: - "--platform=linux/amd64" - - image_templates: - "docker.io/{{ .Env.DOCKERHUB_USERNAME }}/{{ .Env.DOCKERHUB_REPOSITORY }}:{{ .Tag }}-arm64" - "docker.io/{{ .Env.DOCKERHUB_USERNAME }}/{{ .Env.DOCKERHUB_REPOSITORY }}:latest"