-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (28 loc) · 827 Bytes
/
Copy pathDockerfile
File metadata and controls
39 lines (28 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# syntax=docker/dockerfile:1
ARG ALPINE_VERSION=3.21
ARG GO_VERSION=1.25
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
RUN apk add --no-cache git make
ENV CGO_ENABLED=0
ENV GOTOOLCHAIN=auto
WORKDIR /build
# Cache Go dependencies
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
# Set build args for cross-compilation
ARG TARGETOS
ARG TARGETARCH
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
# Build with caching
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
make
FROM alpine:${ALPINE_VERSION}
RUN apk add --no-cache ca-certificates docker-credential-ecr-login
COPY --from=builder /build/build/dockyard /usr/local/bin/dockyard
EXPOSE 5000
ENTRYPOINT ["dockyard"]
CMD ["server"]