diff --git a/.editorconfig b/.editorconfig index 9d9216d8..48cba19a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,3 +12,7 @@ insert_final_newline = true [*.{bash,sh}] indent_style = space indent_size = 4 + +[Dockerfile] +indent_style = space +indent_size = 4 diff --git a/apps/plex/Dockerfile b/apps/plex/Dockerfile index b61c8a6e..89042ae8 100644 --- a/apps/plex/Dockerfile +++ b/apps/plex/Dockerfile @@ -1,20 +1,59 @@ -FROM ghcr.io/onedr0p/ubuntu:jammy-20231004@sha256:6e060e90482632408063d0fbb4b616c77914ef10eaa6b089a00de5815471006c +ARG VERSION +FROM docker.io/library/golang:1.22 as envsubst +ARG VERSION +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT="" +ARG TARGETPLATFORM +ENV CGO_ENABLED=0 \ + GOOS=${TARGETOS} \ + GOARCH=${TARGETARCH} \ + GOARM=${TARGETVARIANT} +RUN go install -ldflags="-s -w" github.com/drone/envsubst/cmd/envsubst@latest + +FROM docker.io/library/ubuntu:22.04 ARG TARGETPLATFORM ARG VERSION ARG CHANNEL +ENV DEBCONF_NONINTERACTIVE_SEEN="true" \ + DEBIAN_FRONTEND="noninteractive" \ + APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE="DontWarn" + ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility" \ - PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server-new" \ PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \ PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \ PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \ - PLEX_MEDIA_SERVER_USER="kah" \ PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" \ PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (onedr0p)" +ENV UMASK="0002" \ + TZ="Etc/UTC" + +USER root + # hadolint ignore=DL3008,DL3015,SC2039,SC2086 RUN \ + apt-get -qq update \ + && \ + apt-get -qq install --no-install-recommends --no-install-suggests -y \ + bash \ + ca-certificates \ + catatonit \ + coreutils \ + curl \ + dnsutils \ + iputils-ping \ + jo \ + jq \ + moreutils \ + tzdata \ + unzip \ + uuid-runtime \ + vim-tiny \ + xmlstarlet \ + && \ case "${TARGETPLATFORM}" in \ 'linux/amd64') \ export ARCH='amd64'; \ @@ -24,18 +63,11 @@ RUN \ ;; \ esac \ && \ - apt-get -qq update \ - && \ - apt-get -qq install -y \ - ca-certificates \ - libusb-dev \ - uuid-runtime \ - xmlstarlet \ - && \ curl -fsSL -o /tmp/plex.deb \ - "${PLEX_DOWNLOAD}/${VERSION}/debian/plexmediaserver_${VERSION}_${ARCH}.deb" \ + "https://downloads.plex.tv/plex-media-server-new/${VERSION}/debian/plexmediaserver_${VERSION}_${ARCH}.deb" \ && \ dpkg -i --force-confold /tmp/plex.deb \ + && chmod -R 755 "${PLEX_MEDIA_SERVER_HOME}" \ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && apt-get autoremove -y \ && apt-get clean \ @@ -44,12 +76,13 @@ RUN \ /etc/default/plexmediaserver \ /tmp/* \ /var/lib/apt/lists/* \ - /var/tmp/ \ - && chown -R root:root /app \ - && chmod -R 755 "${PLEX_MEDIA_SERVER_HOME}" \ - && printf "umask %d\n" "${UMASK}" >> /etc/bash.bashrc + /var/tmp/ WORKDIR "${PLEX_MEDIA_SERVER_HOME}" -USER kah + +COPY --from=envsubst /go/bin/envsubst /usr/local/bin/envsubst + COPY ./apps/plex/entrypoint.sh /entrypoint.sh + +ENTRYPOINT [ "/usr/bin/catatonit", "--" ] CMD ["/entrypoint.sh"] diff --git a/apps/plex/entrypoint.sh b/apps/plex/entrypoint.sh index 0a0d953d..500282a7 100755 --- a/apps/plex/entrypoint.sh +++ b/apps/plex/entrypoint.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -#shellcheck disable=SC1091 -test -f "/scripts/umask.sh" && source "/scripts/umask.sh" - #shellcheck disable=SC2155 export PLEX_MEDIA_SERVER_INFO_MODEL=$(uname -m) #shellcheck disable=SC2155 diff --git a/apps/ubuntu/Dockerfile b/apps/ubuntu/Dockerfile deleted file mode 100644 index ffc5cb7a..00000000 --- a/apps/ubuntu/Dockerfile +++ /dev/null @@ -1,106 +0,0 @@ -ARG VERSION -FROM docker.io/library/alpine:3.19 as builder -ARG VERSION -ARG TARGETOS -ARG TARGETARCH -ARG TARGETVARIANT="" -ARG TARGETPLATFORM -ENV GO111MODULE=on \ - CGO_ENABLED=0 \ - GOOS=${TARGETOS} \ - GOARCH=${TARGETARCH} \ - GOARM=${TARGETVARIANT} \ - GOPATH=/go -ENV PATH $GOPATH/bin:$PATH -#hadolint ignore=DL3018 -RUN \ - apk add --no-cache go upx \ - && go install -ldflags="-s -w" github.com/drone/envsubst/cmd/envsubst@latest \ - && upx /go/bin/envsubst - -FROM docker.io/library/ubuntu:${VERSION} -ARG VERSION -ARG CHANNEL -ARG TARGETPLATFORM -ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64} - -# DEBIAN_FRONTEND: https://askubuntu.com/questions/972516/debian-frontend-environment-variable -# APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE: http://stackoverflow.com/questions/48162574/ddg#49462622 -ENV \ - DEBCONF_NONINTERACTIVE_SEEN=true \ - DEBIAN_FRONTEND="noninteractive" \ - APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn \ - UMASK="0002" \ - TZ="Etc/UTC" - -# hadolint ignore=DL3002 -USER root - -RUN \ - adduser kah \ - --uid 568 \ - --group \ - --system \ - --disabled-password \ - --no-create-home \ - && \ - mkdir -p /config \ - && chown -R kah:kah /config \ - && chmod -R 775 /config - -WORKDIR /app - -# hadolint ignore=DL3008,DL3015 -RUN \ - set -eux \ - && echo 'APT::Install-Recommends "false";' >/etc/apt/apt.conf.d/00recommends \ - && echo 'APT::Install-Suggests "false";' >>/etc/apt/apt.conf.d/00recommends \ - && echo 'APT::Get::Install-Recommends "false";' >>/etc/apt/apt.conf.d/00recommends \ - && echo 'APT::Get::Install-Suggests "false";' >>/etc/apt/apt.conf.d/00recommends \ - && \ - apt-get -qq update \ - && \ - apt-get install -y \ - bash \ - ca-certificates \ - catatonit \ - coreutils \ - curl \ - dnsutils \ - iputils-ping \ - jo \ - jq \ - locales \ - moreutils \ - pv \ - tzdata \ - vim-tiny \ - unzip \ - wget \ - && \ - localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \ - && ln -s /usr/bin/vim.tiny /usr/local/bin/vi \ - && ln -s /usr/bin/vim.tiny /usr/local/bin/vim \ - && ln -s /usr/bin/vim.tiny /usr/local/bin/nano \ - && ln -s /usr/bin/vim.tiny /usr/local/bin/emacs \ - && ln -s /usr/bin/catatonit /usr/bin/tini \ - && chown -R kah:kah /app \ - && \ - printf "/bin/bash /scripts/greeting.sh\n" >> /etc/bash.bashrc \ - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ - && apt-get autoremove -y \ - && apt-get clean \ - && \ - rm -rf \ - /tmp/* \ - /var/lib/apt/lists/* \ - /var/cache/apt/* \ - /var/tmp/* - -ENV LANG en_US.UTF-8 - -VOLUME ["/config"] -COPY ./apps/ubuntu/scripts /scripts -COPY --from=builder /go/bin/envsubst /usr/local/bin/envsubst - -ENTRYPOINT [ "/usr/bin/catatonit", "--" ] diff --git a/apps/ubuntu/ci/goss.yaml b/apps/ubuntu/ci/goss.yaml deleted file mode 100644 index e497134c..00000000 --- a/apps/ubuntu/ci/goss.yaml +++ /dev/null @@ -1,24 +0,0 @@ ---- -# https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#file -file: - /scripts/greeting.sh: - exists: true - /scripts/umask.sh: - exists: true - /scripts/vpn.sh: - exists: true - /usr/local/bin/envsubst: - exists: true - -# https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#group -group: - kah: - exists: true - gid: 568 - -# https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#user -user: - kah: - exists: true - uid: 568 - gid: 568 diff --git a/apps/ubuntu/ci/latest.sh b/apps/ubuntu/ci/latest.sh deleted file mode 100755 index 5c38a822..00000000 --- a/apps/ubuntu/ci/latest.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -channel=$1 -version=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/ubuntu/tags?ordering=name&name=$channel" | jq --raw-output --arg s "$channel" '.results[] | select(.name | contains($s)) | .name' 2>/dev/null | head -n1) -version="${version#*v}" -version="${version#*release-}" -printf "%s" "${version}" diff --git a/apps/ubuntu/metadata.yaml b/apps/ubuntu/metadata.yaml deleted file mode 100644 index 738b0e44..00000000 --- a/apps/ubuntu/metadata.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -app: ubuntu -base: true -channels: - - name: jammy - platforms: ["linux/amd64", "linux/arm64"] - stable: true - tests: - enabled: true - type: cli diff --git a/apps/ubuntu/scripts/greeting.sh b/apps/ubuntu/scripts/greeting.sh deleted file mode 100755 index 0d220e37..00000000 --- a/apps/ubuntu/scripts/greeting.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -echo " -You are entering the vicinity of an area adjacent to a location. -The kind of place where there might be a monster, or some kind of weird mirror. -These are just examples; it could also be something much better. -" diff --git a/apps/ubuntu/scripts/sleep.sh b/apps/ubuntu/scripts/sleep.sh deleted file mode 100755 index 63e42359..00000000 --- a/apps/ubuntu/scripts/sleep.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -min_seconds="${1:-1}" -max_seconds="${2:-3600}" -seconds="$(shuf -i "${min_seconds}"-"${max_seconds}" -n 1)" - -function logz { - msg="${1}" - level="${2:-info}" - printf "\e[1;32m%-6s\e[m\n" "timestamp=\"$(date +"%Y-%m-%dT%H:%M:%S%z")\" level=\"${level}\" msg=\"${msg}\"" -} - -function datez { - secs="${1}" - printf "%dh%dm%ds" $((secs/3600)) $((secs%3600/60)) $((secs%60)) -} - -printf "\e[1;32m%-6s\e[m\n" "$(logz "min seconds set to ${min_seconds}" "debug")" -printf "\e[1;32m%-6s\e[m\n" "$(logz "max seconds set to ${max_seconds}" "debug")" - -printf "\e[1;32m%-6s\e[m\n" "$(logz "sleeping for $(datez "${seconds}")" "info")" - -for ((i=seconds;i>0;i--)); do - printf "\e[1;32m%-6s\e[m\n" "$(logz "sleeping for $(datez "${i}")" "info")" - sleep 1 -done - -printf "\e[1;32m%-6s\e[m\n" "$(logz "done" "debug")" diff --git a/apps/ubuntu/scripts/umask.sh b/apps/ubuntu/scripts/umask.sh deleted file mode 100755 index bea3cc35..00000000 --- a/apps/ubuntu/scripts/umask.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -umask "${UMASK:-0002}" diff --git a/apps/ubuntu/scripts/vpn.sh b/apps/ubuntu/scripts/vpn.sh deleted file mode 100755 index 936ed509..00000000 --- a/apps/ubuntu/scripts/vpn.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -if [[ "${WAIT_FOR_VPN:-"false"}" == "true" ]]; then - echo "Waiting for VPN to be connected..." - while ! grep -s -q "connected" /shared/vpnstatus; do - echo "VPN not connected" - sleep 2 - done - echo "VPN Connected, starting application..." -fi