diff --git a/Dockerfile b/Dockerfile index 7c3f242..74a48e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,17 @@ +# build stage FROM golang:1.22-alpine AS build -# Set destination for COPY of gui files WORKDIR /src # Download Go modules COPY go.mod go.sum ./ RUN go mod download -# Copy the source code. Note the slash at the end, as explained in -# https://docs.docker.com/reference/dockerfile/#copy -# COPY *.go ./ - -# RUN CGO_ENABLED=0 GOOS=linux go build -o /adonis +# this could be simplified a lot by being stricter on what we copy. COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -o adonis . +# copy only binary and static files to slim image size FROM alpine WORKDIR /app @@ -22,13 +19,7 @@ WORKDIR /app COPY --from=build /src/adonis . COPY --from=build /src/static ./static -# Build -# Optional: -# To bind to a TCP port, runtime parameters must be supplied to the docker command. -# But we can document in the Dockerfile what ports -# the application is going to listen on by default. -# https://docs.docker.com/reference/dockerfile/#expose +# application binds to 80 by default EXPOSE 80 -# Run ENTRYPOINT ["/app/adonis"]