From f1fcd37ebd01f161e4afafba23518c4a855ab384 Mon Sep 17 00:00:00 2001 From: musselman Date: Tue, 21 Nov 2023 14:56:18 -0600 Subject: [PATCH] Hail Mary --- Dockerfile | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9515e14..e489d56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,34 @@ -# Stage 1: Build the Go application -FROM docker.io/golang:1.20-alpine as builder +# Set the base image +FROM golang:1.21-alpine as builder RUN apk --no-cache add ca-certificates git -WORKDIR /build -COPY go.mod go.sum ./ -RUN go mod download +# Set the working directory +WORKDIR /app -COPY editor_templates/ editor_templates/ -COPY templates/ templates/ -COPY static/ static/ -COPY wait-for-postgres.sh ./ +# Copy the Go application source code to the container +COPY . . -COPY . ./ -RUN go build -o /home/notatio/notatio +# Build the Go application +RUN go build -o notatio -# Stage 2: Create the final image -FROM docker.io/library/alpine:3.18.4 -# Add the user notatio and create its home directory -RUN adduser --home /home/notatio --disabled-password --gecos "" notatio +# Switch to the base Alpine image +FROM alpine:latest + +# Set the user and working directory +RUN adduser -D notatio USER notatio -WORKDIR / +WORKDIR /home/notatio -COPY --from=builder /notatio /home/notatio +# Copy necessary files to the user's directory +COPY --from=builder /app/notatio . +COPY --from=builder /app/editor_templates ./editor_templates +COPY --from=builder /app/templates ./templates +COPY --from=builder /app/static ./static +COPY --from=builder /app/wait.sh . -COPY --from=builder /build/templates/ /home/notatio/templates/ -COPY --from=builder /build/editor_templates/ /home/notatio/editor_templates/ -COPY --from=builder /build/static/ /home/notatio/static/ -COPY --from=builder /build/wait-for-postgres.sh /home/notatio/wait-for-postgres.sh +# Make the wait.sh script executable +RUN chmod +x wait.sh -EXPOSE 9991 +# Wait for 10 seconds before starting the application ENTRYPOINT ["sh", "-c", "sleep 10 && cd && ./notatio"] LABEL name=notatio version=latest