2023-11-21 04:10:40 +00:00
|
|
|
# Stage 1: Build the Go application
|
|
|
|
FROM docker.io/golang:1.20-alpine as builder
|
|
|
|
RUN apk --no-cache add ca-certificates git
|
|
|
|
WORKDIR /build
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
COPY editor_templates/ editor_templates/
|
|
|
|
COPY templates/ templates/
|
|
|
|
COPY static/ static/
|
|
|
|
COPY wait-for-postgres.sh ./
|
|
|
|
|
|
|
|
COPY . ./
|
2023-11-21 20:03:30 +00:00
|
|
|
RUN go build -o /home/notatio/notatio
|
2023-11-21 04:10:40 +00:00
|
|
|
|
|
|
|
# Stage 2: Create the final image
|
2023-11-21 18:45:52 +00:00
|
|
|
FROM docker.io/library/alpine:3.18.4
|
2023-11-21 18:54:35 +00:00
|
|
|
# Add the user notatio and create its home directory
|
2023-11-21 20:23:56 +00:00
|
|
|
RUN adduser --home /home/notatio --disabled-password --gecos "" notatio
|
2023-11-21 18:45:52 +00:00
|
|
|
USER notatio
|
2023-11-21 04:10:40 +00:00
|
|
|
WORKDIR /
|
|
|
|
|
2023-11-21 20:03:30 +00:00
|
|
|
COPY --from=builder /notatio /home/notatio/notatio
|
2023-11-21 04:10:40 +00:00
|
|
|
|
2023-11-21 20:03:30 +00:00
|
|
|
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
|
2023-11-21 04:10:40 +00:00
|
|
|
|
|
|
|
EXPOSE 9991
|
2023-11-21 20:03:30 +00:00
|
|
|
ENTRYPOINT ["sh", "-c", "sleep 10 && cd && ./notatio"]
|
2023-11-21 04:10:40 +00:00
|
|
|
LABEL name=notatio version=latest
|
2023-11-21 18:45:52 +00:00
|
|
|
|
|
|
|
HEALTHCHECK --interval=5m --timeout=3s \
|
|
|
|
CMD curl -f http://localhost/ || exit 1
|