halfrost-leetcode-go
SUCCESS
5m 32s
History Source
SummaryIterations1Transcript10Dockerfile
Dockerfile37 lines · 745 chars
# syntax=docker/dockerfile:1

FROM golang:tip-alpine3.23 AS builder

# Install git for module fetching
RUN apk add --no-cache git

ENV CGO_ENABLED=0

WORKDIR /build

# Copy the go.mod and go.sum first to leverage layer caching
COPY go.mod go.sum ./

# We need the full repo because of local module replacements; copy all
COPY . .

# Fetch dependencies
RUN go mod download

# Build the project from sources; build the main CLI under ctl
RUN go build -trimpath -o leetcode-go ./ctl

FROM alpine:3.18

# Install CA certificates for TLS
RUN apk add --no-cache ca-certificates

WORKDIR /root

# Copy the binary from builder
COPY --from=builder /build/leetcode-go /usr/local/bin/leetcode-go

# Run the CLI by default
ENTRYPOINT ["leetcode-go"]
CMD []