docker healthcheck

This commit is contained in:
2025-02-28 21:46:06 +00:00
parent 2c9ad491ff
commit f700b904e0
9 changed files with 44 additions and 40 deletions
+5 -4
View File
@@ -3,15 +3,16 @@ WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o ipinfo .
RUN go build -ldflags="-s -w" -o ipinfo .
RUN go build -ldflags="-s -w" -o healthcheck ./healthcheck/healthcheck.go
RUN go install github.com/maxmind/geoipupdate/v7/cmd/geoipupdate@latest
RUN mkdir -p /build/data
FROM alpine:latest
RUN apk add --no-cache curl tzdata busybox-suid
WORKDIR /app
COPY --from=builder /build/ipinfo .
COPY --from=builder /build/healthcheck .
COPY --from=builder /go/bin/geoipupdate /usr/local/bin/geoipupdate
ENV GEOIPUPDATE_ACCOUNT_ID=${GEOIPUPDATE_ACCOUNT_ID}
@@ -27,8 +28,8 @@ RUN echo "AccountID ${GEOIPUPDATE_ACCOUNT_ID}" > /etc/GeoIP.conf && \
RUN echo "0 0 * * * geoipupdate >> /var/log/geoipupdate.log 2>&1" > /etc/crontabs/root
RUN cat /etc/crontabs/root
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD curl --fail http://localhost:3000/health || exit 1
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s CMD ["./healthcheck"]
EXPOSE 3000
CMD ["sh", "-c", "geoipupdate && ./ipinfo"]
CMD ["./ipinfo"]