From 204045ba5d8c13ab5545644737f9d795027675c2 Mon Sep 17 00:00:00 2001 From: Nat1anWasTaken Date: Mon, 13 May 2024 21:31:24 +0800 Subject: [PATCH] chore(*): remove unnecessary Lavalink and Python application scripts and configurations --- Dockerfile | 69 +++++++++---------- .../s6-rc.d/lavalink-server/rootless-run | 19 ----- .../s6-overlay/s6-rc.d/lavalink-server/run | 3 - .../s6-overlay/s6-rc.d/lavalink-server/type | 1 - .../etc/s6-overlay/s6-rc.d/lavalink-server/up | 1 - .../s6-rc.d/python-application/rootless-run | 4 -- .../s6-overlay/s6-rc.d/python-application/run | 3 - .../s6-rc.d/python-application/type | 1 - .../s6-overlay/s6-rc.d/python-application/up | 1 - .../s6-rc.d/user/contents.d/lavalink-server | 0 .../user/contents.d/python-application | 0 11 files changed, 31 insertions(+), 71 deletions(-) delete mode 100644 docker/etc/s6-overlay/s6-rc.d/lavalink-server/rootless-run delete mode 100644 docker/etc/s6-overlay/s6-rc.d/lavalink-server/run delete mode 100644 docker/etc/s6-overlay/s6-rc.d/lavalink-server/type delete mode 100644 docker/etc/s6-overlay/s6-rc.d/lavalink-server/up delete mode 100644 docker/etc/s6-overlay/s6-rc.d/python-application/rootless-run delete mode 100644 docker/etc/s6-overlay/s6-rc.d/python-application/run delete mode 100644 docker/etc/s6-overlay/s6-rc.d/python-application/type delete mode 100644 docker/etc/s6-overlay/s6-rc.d/python-application/up delete mode 100644 docker/etc/s6-overlay/s6-rc.d/user/contents.d/lavalink-server delete mode 100644 docker/etc/s6-overlay/s6-rc.d/user/contents.d/python-application diff --git a/Dockerfile b/Dockerfile index 0df186af..54492060 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,31 @@ -FROM python:3.12.3-slim-bookworm - -ARG S6_OVERLAY_VERSION=3.1.6.2 LAVALINK_VERSION=4.0.4 DEBIAN_FRONTEND="noninteractive" - -ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp -ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp -ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp -ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp - -RUN apt-get update && \ - apt-get install -y git curl jq openjdk-17-jre-headless xz-utils \ - gcc g++ python3-dev libffi-dev build-essential cmake libjpeg-dev && \ - apt-get clean && \ - tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && \ - tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz && \ - tar -C / -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz && \ - tar -C / -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz && \ - rm -rf /tmp/* && \ - groupadd -g 1200 lava && \ - useradd lava --system --gid 1200 --uid 1200 --create-home && \ - mkdir /lava && \ - chown 1200:1200 /lava - -COPY --chown=1200:1200 . /lava -WORKDIR /lava -USER lava -RUN rm ./docker -r && \ - curl -fsSL https://github.com/lavalink-devs/Lavalink/releases/download/${LAVALINK_VERSION}/Lavalink.jar -o /lava/lavalink.jar - -USER root -ENV S6_VERBOSITY=1 \ - S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \ - S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \ - SHELL=/bin/bash -COPY --chmod=755 ./docker / -RUN python -m pip install -r /lava/requirements.txt - -ENTRYPOINT ["/init"] \ No newline at end of file +FROM python:3.12.3-slim as base + +ENV PYTHONDONTWRITEBYTECODE=1 + +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +ARG UID=10001 +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/nonexistent" \ + --shell "/sbin/nologin" \ + --no-create-home \ + --uid "${UID}" \ + appuser + +RUN apt-get update && apt-get install -y git + +RUN --mount=type=cache,target=/root/.cache/pip \ + --mount=type=bind,source=requirements.txt,target=requirements.txt \ + python -m pip install -r requirements.txt + +COPY . . + +RUN chown -R appuser:appuser /app + +USER appuser + +CMD python main.py diff --git a/docker/etc/s6-overlay/s6-rc.d/lavalink-server/rootless-run b/docker/etc/s6-overlay/s6-rc.d/lavalink-server/rootless-run deleted file mode 100644 index 4f0f4237..00000000 --- a/docker/etc/s6-overlay/s6-rc.d/lavalink-server/rootless-run +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/with-contenv bash - -cd /lava -if [[ "${LAVALINK_SERVER}" == "true" ]] || [[ "${LAVALINK_SERVER}" == "TRUE" ]] || [[ "${LAVALINK_SERVER}" == "1" ]]; then - cd /lava - cp /lava/configs/application.yml /lava - - if [[ -z "${LOGGING_LEVEL_ROOT}" ]]; then - export LOGGING_LEVEL_ROOT=WARN - fi - if [[ -z "${LOGGING_LEVEL_LAVALINK}" ]]; then - export LOGGING_LEVEL_LAVALINK=WARN - fi - - java -jar ./lavalink.jar -else - echo "Not starting lavalink server" - sleep infinity -fi \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/lavalink-server/run b/docker/etc/s6-overlay/s6-rc.d/lavalink-server/run deleted file mode 100644 index 48519963..00000000 --- a/docker/etc/s6-overlay/s6-rc.d/lavalink-server/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/with-contenv bash - -exec s6-setuidgid lava /etc/s6-overlay/s6-rc.d/lavalink-server/rootless-run \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/lavalink-server/type b/docker/etc/s6-overlay/s6-rc.d/lavalink-server/type deleted file mode 100644 index 1780f9f4..00000000 --- a/docker/etc/s6-overlay/s6-rc.d/lavalink-server/type +++ /dev/null @@ -1 +0,0 @@ -longrun \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/lavalink-server/up b/docker/etc/s6-overlay/s6-rc.d/lavalink-server/up deleted file mode 100644 index 1abd8a11..00000000 --- a/docker/etc/s6-overlay/s6-rc.d/lavalink-server/up +++ /dev/null @@ -1 +0,0 @@ -/etc/s6-overlay/s6-rc.d/lavalink-server/run \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/python-application/rootless-run b/docker/etc/s6-overlay/s6-rc.d/python-application/rootless-run deleted file mode 100644 index 058bdf9b..00000000 --- a/docker/etc/s6-overlay/s6-rc.d/python-application/rootless-run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/with-contenv bash - -cd /lava -python main.py \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/python-application/run b/docker/etc/s6-overlay/s6-rc.d/python-application/run deleted file mode 100644 index 62191c07..00000000 --- a/docker/etc/s6-overlay/s6-rc.d/python-application/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/with-contenv bash - -exec s6-setuidgid lava /etc/s6-overlay/s6-rc.d/python-application/rootless-run \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/python-application/type b/docker/etc/s6-overlay/s6-rc.d/python-application/type deleted file mode 100644 index 1780f9f4..00000000 --- a/docker/etc/s6-overlay/s6-rc.d/python-application/type +++ /dev/null @@ -1 +0,0 @@ -longrun \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/python-application/up b/docker/etc/s6-overlay/s6-rc.d/python-application/up deleted file mode 100644 index e9d848a9..00000000 --- a/docker/etc/s6-overlay/s6-rc.d/python-application/up +++ /dev/null @@ -1 +0,0 @@ -/etc/s6-overlay/s6-rc.d/python-application/run \ No newline at end of file diff --git a/docker/etc/s6-overlay/s6-rc.d/user/contents.d/lavalink-server b/docker/etc/s6-overlay/s6-rc.d/user/contents.d/lavalink-server deleted file mode 100644 index e69de29b..00000000 diff --git a/docker/etc/s6-overlay/s6-rc.d/user/contents.d/python-application b/docker/etc/s6-overlay/s6-rc.d/user/contents.d/python-application deleted file mode 100644 index e69de29b..00000000