Skip to content

Commit

Permalink
optimize dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Apr 30, 2023
1 parent e324225 commit 88377d6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cmd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
FROM golang:1.18-alpine AS build

ARG VERSION=dev
FROM --platform=$BUILDPLATFORM golang:1.18-alpine AS build

WORKDIR /build

Expand All @@ -10,7 +8,16 @@ RUN go mod download

COPY . .

RUN CGO_ENABLED=0 go build -ldflags="-X 'main.version=${VERSION}'-w -s" -o bot cmd/main.go
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=dev

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
go build -ldflags="-X 'main.version=${VERSION}'-w -s" -o bot cmd/main.go

FROM alpine

Expand Down

0 comments on commit 88377d6

Please sign in to comment.