-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile.multi
More file actions
44 lines (32 loc) · 1.06 KB
/
Dockerfile.multi
File metadata and controls
44 lines (32 loc) · 1.06 KB
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
40
41
42
43
44
# Multi-architecture Dockerfile for the Vicohome CLI
# This Dockerfile builds the CLI for multiple architectures (amd64, arm64)
# It uses a multi-stage build to keep the final image small
FROM --platform=${BUILDPLATFORM} golang:1.23-alpine AS builder
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=dev
WORKDIR /src
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build for the target platform
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -ldflags="-X 'github.com/dydx/vico-cli/cmd.Version=${VERSION}'" \
-o /out/vicohome main.go
# Create the final lightweight image
FROM --platform=${TARGETPLATFORM} alpine:3.18
WORKDIR /app
# Install CA certificates for HTTPS requests
RUN apk --no-cache add ca-certificates
# Copy the binary from the builder stage
COPY --from=builder /out/vicohome /app/vicohome
# Create a non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser
# Set the entrypoint
ENTRYPOINT ["/app/vicohome"]
CMD ["version"]