From d5f8c9fa82a906a5ba407dbfd4131a7182f97025 Mon Sep 17 00:00:00 2001 From: darksaid98 Date: Tue, 31 Dec 2024 06:02:38 +0100 Subject: [PATCH] fix(yagpdb): use alpine --- bot/yagpdb/Dockerfile | 16 +++++++--------- bot/yagpdb/entrypoint.sh | 12 +++++++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bot/yagpdb/Dockerfile b/bot/yagpdb/Dockerfile index 9c0695d..4340ed4 100644 --- a/bot/yagpdb/Dockerfile +++ b/bot/yagpdb/Dockerfile @@ -20,29 +20,27 @@ RUN CGO_ENABLED=0 GOOS=linux go build -v -ldflags "-X github.com/botlabs-gg/yagp -FROM --platform=$TARGETOS/$TARGETARCH debian:bookworm-slim - -ENV DEBIAN_FRONTEND noninteractive +FROM --platform=$TARGETOS/$TARGETARCH alpine:latest # Dependencies: ca-certificates for client TLS, tzdata for timezone and ffmpeg for soundboard support -RUN apt update -y \ - && apt upgrade -y \ - && apt install -y ca-certificates tini ffmpeg tzdata +RUN apk update \ + && apk upgrade \ + && apk --no-cache add autoconf ca-certificates ffmpeg tzdata tini iproute2 iputils-ping bind-tools curl ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 -RUN useradd -m -d /home/container -s /bin/bash container +RUN adduser -D -h /home/container container -s /bin/bash container USER container ENV USER=container HOME=/home/container WORKDIR /home/container COPY --from=builder /appbuild/yagpdb/cmd/yagpdb/yagpdb /usr/bin/yagpdb -RUN chmod +x /usr/bin/yagpdb +# RUN chmod +x /usr/bin/yagpdb STOPSIGNAL SIGINT COPY --chown=container:container ./entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh -ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +ENTRYPOINT ["/sbin/tini", "-g", "--"] CMD ["/entrypoint.sh"] diff --git a/bot/yagpdb/entrypoint.sh b/bot/yagpdb/entrypoint.sh index d72adfe..029f283 100644 --- a/bot/yagpdb/entrypoint.sh +++ b/bot/yagpdb/entrypoint.sh @@ -22,14 +22,20 @@ # SOFTWARE. # +# Switch to the container's working directory +cd /home/container || exit 1 + +# Wait for the container to fully initialize +sleep 1 + # Default the TZ environment variable to UTC. TZ=${TZ:-UTC} export TZ -# Switch to the container's working directory -cd /home/container || exit 1 +# Set environment variable that holds the Internal Docker IP +INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') +export INTERNAL_IP -# Add custom binary export PATH=$PATH:/root/.local/bin # Convert all of the "{{VARIABLE}}" parts of the command into the expected shell