trimmed extra comments and described two build stages
This commit is contained in:
parent
f0d486fd6c
commit
7088a05f8e
17
Dockerfile
17
Dockerfile
@ -1,20 +1,17 @@
|
|||||||
|
# build stage
|
||||||
FROM golang:1.22-alpine AS build
|
FROM golang:1.22-alpine AS build
|
||||||
|
|
||||||
# Set destination for COPY of gui files
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Download Go modules
|
# Download Go modules
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
# Copy the source code. Note the slash at the end, as explained in
|
# this could be simplified a lot by being stricter on what we copy.
|
||||||
# https://docs.docker.com/reference/dockerfile/#copy
|
|
||||||
# COPY *.go ./
|
|
||||||
|
|
||||||
# RUN CGO_ENABLED=0 GOOS=linux go build -o /adonis
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -o adonis .
|
RUN CGO_ENABLED=0 GOOS=linux go build -o adonis .
|
||||||
|
|
||||||
|
# copy only binary and static files to slim image size
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@ -22,13 +19,7 @@ WORKDIR /app
|
|||||||
COPY --from=build /src/adonis .
|
COPY --from=build /src/adonis .
|
||||||
COPY --from=build /src/static ./static
|
COPY --from=build /src/static ./static
|
||||||
|
|
||||||
# Build
|
# application binds to 80 by default
|
||||||
# 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
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# Run
|
|
||||||
ENTRYPOINT ["/app/adonis"]
|
ENTRYPOINT ["/app/adonis"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user