-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dockerfile: switch to alpine for much smaller image
- Loading branch information
Showing
1 changed file
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |