Skip to content

Commit

Permalink
Dockerfile: switch to alpine for much smaller image
Browse files Browse the repository at this point in the history
  • Loading branch information
msf committed Jun 19, 2024
1 parent f28d588 commit bb13fbb
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
FROM golang:1.22-bookworm AS builder
FROM golang:1.22-alpine AS builder

RUN apt update && apt install -y curl make
# dependencies to build the project & dependencies
RUN apk add --no-cache git make curl gcc musl-dev binutils-gold

# first copy just enough to pull all dependencies, to cache this layer
# First copy just enough to pull all dependencies, to cache this layer
COPY go.mod go.sum Makefile /app/
WORKDIR /app/
RUN make setup

# lint, build, etc..
# Copy the rest of the source code and build the Go binary
COPY . /app/
RUN make test
RUN make build

FROM debian:bookworm-slim
RUN apt update \
&& apt install -y ca-certificates \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
# Stage 2: Create a minimal runtime image
FROM alpine:latest

# Install ca-certificates
RUN apk add --no-cache ca-certificates

COPY --from=builder /app/indexer /
ENTRYPOINT ["/indexer"]

0 comments on commit bb13fbb

Please sign in to comment.