FreePad/Dockerfile

33 lines
694 B
Docker
Raw Permalink Normal View History

# Importing golang 1.18 to use as a builder for our source
2022-06-01 21:24:03 +03:00
FROM golang:1.18 as builder
# Use the /src directory as a workdir
WORKDIR /src
2022-06-01 21:24:03 +03:00
# Copy the src to /src
2022-06-01 21:24:03 +03:00
COPY . ./
# Download dependencies
RUN go mod download
# Build the executable
2022-06-01 21:24:03 +03:00
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o freepad .
# Import alpine linux as a base
FROM scratch
2022-06-01 18:29:17 +03:00
LABEL version="1.4.0"
2022-06-01 21:24:03 +03:00
# Copy the files from the builder to the new image
COPY --from=builder /src/freepad /app/freepad
COPY --from=builder /src/templates /app/templates
COPY --from=builder /src/static /app/static
# Make /app the work directory
WORKDIR /app
# Expose the listening port
EXPOSE 8080
# Run the program
ENTRYPOINT ["./freepad"]