Improve Dockerfile

This commit is contained in:
Shiny Nematoda
2023-05-19 15:19:44 +00:00
parent 92dd64ee74
commit a256a446f0
2 changed files with 12 additions and 5 deletions
+2 -1
View File
@@ -2,4 +2,5 @@
.gitignore
.dockerignore
*.md
*.txt
*.txt
*.yml
+10 -4
View File
@@ -1,6 +1,6 @@
FROM --platform=$BUILDPLATFORM golang:alpine AS build
FROM --platform=$BUILDPLATFORM docker.io/golang:latest AS build
WORKDIR /app/
WORKDIR /src
RUN apk --no-cache add ca-certificates
@@ -9,8 +9,14 @@ COPY . .
ARG TARGETOS TARGETARCH
RUN GOPROXY=https://proxy.golang.org,https://goproxy.cn go mod download && \
CGO=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "-s -w"
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags "-s -w" -o /src/hyperpipe-backend
FROM scratch as bin
WORKDIR /app
COPY --from=build /etc/ssl/certs/cacertificates.crt /etc/ssl/certs/
COPY --from=build /src/hyperpipe-backend .
EXPOSE 3000
CMD ./hyperpipe-backend
CMD ./hyperpipe-backend