Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker Healthcheck to both containers. #893

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ RUN chmod +x /app/api
LABEL Name=homebox Version=0.0.1
LABEL org.opencontainers.image.source="https://github.com/hay-kot/homebox"
EXPOSE 7745
HEALTHCHECK --interval=30s \
--timeout=5s \
--start-period=5s \
--retries=3 \
CMD [ "/usr/bin/wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:7745/api/v1/status" ]
WORKDIR /app
VOLUME [ "/data" ]

Expand Down
15 changes: 15 additions & 0 deletions Dockerfile.rootless
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ FROM golang:alpine AS builder
ARG BUILD_TIME
ARG COMMIT
ARG VERSION
ARG BUSYBOX_VERSION=1.31.0-i686-uclibc
RUN apk update && \
apk upgrade && \
apk add --update git build-base gcc g++
Expand All @@ -30,6 +31,14 @@ RUN CGO_ENABLED=0 GOOS=linux go build \
# create a directory so that we can copy it in the next stage
mkdir /data

# Downloading Wget
ADD https://busybox.net/downloads/binaries/$BUSYBOX_VERSION/busybox_WGET /wget
RUN chmod a+x /wget

FROM gcr.io/distroless/java

COPY --from=builder /wget /usr/bin/wget

# Production Stage
FROM gcr.io/distroless/static

Expand All @@ -41,10 +50,16 @@ ENV HBOX_STORAGE_SQLITE_URL=/data/homebox.db?_fk=1
# change the ownership to the low-privileged user
COPY --from=builder --chown=nonroot /go/bin/api /app
COPY --from=builder --chown=nonroot /data /data
COPY --from=builder --chown=nonroot /wget /usr/bin/wget

LABEL Name=homebox Version=0.0.1
LABEL org.opencontainers.image.source="https://github.com/hay-kot/homebox"
EXPOSE 7745
HEALTHCHECK --interval=30s \
--timeout=5s \
--start-period=5s \
--retries=3 \
CMD [ "/usr/bin/wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:7745/api/v1/status" ]
VOLUME [ "/data" ]

# Drop root and run as low-privileged user
Expand Down