29 lines
571 B
Docker
29 lines
571 B
Docker
# build stage
|
|
FROM golang:1.22-alpine AS build
|
|
|
|
WORKDIR /src
|
|
|
|
# Download Go modules
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# this could be simplified a lot by being stricter on what we copy.
|
|
COPY . .
|
|
|
|
ENV GOCACHE=/root/.cache/go-build
|
|
|
|
RUN --mount=type=cache,target="/root/.cache/go-build" CGO_ENABLED=0 GOOS=linux go build -o adonis .
|
|
|
|
# copy only binary and static files to slim image size
|
|
FROM alpine
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=build /src/adonis .
|
|
COPY --from=build /src/static ./static
|
|
|
|
# application binds to 80 by default
|
|
EXPOSE 80
|
|
|
|
ENTRYPOINT ["/app/adonis"]
|