From 8757351d9a3ff2485f4fd15052177aa9692c0381 Mon Sep 17 00:00:00 2001 From: Henning Bocklage Date: Sun, 30 May 2021 01:10:34 +0200 Subject: [PATCH] Next Gen Deemix --- .gitlab-ci.yml | 6 +- CHANGELOG.md | 2 + Dockerfile | 153 +++++++++++++++++++++++----- Dockerfile.arm32v7 | 53 ---------- Dockerfile.arm64v8 | 54 ---------- root/etc/cont-init.d/10-fix_folders | 9 ++ root/etc/cont-init.d/15-checks | 9 -- root/etc/cont-init.d/20-download | 22 ---- root/etc/cont-init.d/30-config | 13 --- root/etc/cont-init.d/40-install | 30 ------ root/etc/services.d/deemix/run | 23 +---- 11 files changed, 145 insertions(+), 229 deletions(-) delete mode 100644 Dockerfile.arm32v7 delete mode 100644 Dockerfile.arm64v8 create mode 100644 root/etc/cont-init.d/10-fix_folders delete mode 100644 root/etc/cont-init.d/15-checks delete mode 100644 root/etc/cont-init.d/20-download delete mode 100644 root/etc/cont-init.d/30-config delete mode 100644 root/etc/cont-init.d/40-install diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8740414..2ff136b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ stages: variables: IMAGE: registry.gitlab.com/bockiii/deemix-docker - IMAGE_TAG: latest + IMAGE_TAG: ng DOCKER_CLI_EXPERIMENTAL: enabled before_script: @@ -19,8 +19,8 @@ build: stage: build script: - docker run --rm --privileged multiarch/qemu-user-static:register --reset - - docker build --pull -f Dockerfile.arm64v8 --build-arg BUILDDATE=$CI_JOB_TIMESTAMP -t $IMAGE:arm64v8-${IMAGE_TAG} . - - docker build --pull -f Dockerfile.arm32v7 --build-arg BUILDDATE=$CI_JOB_TIMESTAMP -t $IMAGE:arm32v7-${IMAGE_TAG} . + - docker build --pull -f Dockerfile --build-arg BUILDDATE=$CI_JOB_TIMESTAMP --build-arg FROM_ARCH=arm64v8 -t $IMAGE:arm64v8-${IMAGE_TAG} . + - docker build --pull -f Dockerfile --build-arg BUILDDATE=$CI_JOB_TIMESTAMP --build-arg FROM_ARCH=arm32v7 -t $IMAGE:arm32v7-${IMAGE_TAG} . - docker build --pull --build-arg BUILDDATE=$CI_JOB_TIMESTAMP -t $IMAGE:amd64-${IMAGE_TAG} . - docker push $IMAGE:arm64v8-${IMAGE_TAG} - docker push $IMAGE:arm32v7-${IMAGE_TAG} diff --git a/CHANGELOG.md b/CHANGELOG.md index ceef75f..3eb9f74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ # Changelog +## 2021-05-30 +- Added next gen version of deemix as container variant ## 2021-04-12 - Added "packagedate" to see when the source was pulled in the logfiles ## 2021-03-29 diff --git a/Dockerfile b/Dockerfile index b157766..1a72aef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,26 @@ -FROM lsiobase/alpine:3.13 +ARG FROM_ARCH=amd64 + +# Multi-stage build, see https://docs.docker.com/develop/develop-images/multistage-build/ +FROM alpine AS builder + +# Download QEMU + +RUN case "${FROM_ARCH}" in \ + amd64) echo "X86_64 detected. No QEMU needed.";; \ + arm32v7) QEMU_ARCH='arm';; \ + arm64v8) QEMU_ARCH='aarch64';; \ + esac \ + +ADD https://github.com/balena-io/qemu/releases/download/v5.2.0%2Bbalena4/qemu-5.2.0.balena4-$QEMU_ARCH.tar.gz . +RUN tar zxvf qemu-5.2.0.balena4-$QEMU_ARCH.tar.gz --strip-components 1 ARG BUILDDATE ENV BUILDDATEENV=${BUILDDATE} +FROM lsiobase/alpine:%FROM_ARCH-3.13 + +COPY --from=builder qemu-$QEMU_ARCH-static /usr/bin + LABEL \ app.deemix.image.created="${BUILDDATE}" \ app.deemix.image.url="https://gitlab.com/Bockiii/deemix-docker" \ @@ -10,34 +28,115 @@ LABEL \ app.deemix.image.description="Docker image for Deemix and the pyweb frontend" \ maintainer="Bocki" +ENV NODE_VERSION 16.2.0 + +RUN apk add --no-cache \ + libstdc++ \ + && apk add --no-cache --virtual .build-deps \ + curl \ + && ARCH= && alpineArch="$(apk --print-arch)" \ + && case "${alpineArch##*-}" in \ + x86_64) \ + ARCH='x64' \ + CHECKSUM="ac3cb1aa724b2db17f5be9463b08b6c1b5cb281c660e6a4526ee67e1dd4ba24b" \ + ;; \ + *) ;; \ + esac \ + && if [ -n "${CHECKSUM}" ]; then \ + set -eu; \ + curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \ + echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \ + && tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ + && ln -s /usr/local/bin/node /usr/local/bin/nodejs; \ + else \ + echo "Building from source" \ + # backup build + && apk add --no-cache --virtual .build-deps-full \ + binutils-gold \ + g++ \ + gcc \ + gnupg \ + libgcc \ + linux-headers \ + make \ + python3 \ + # gpg keys listed at https://github.com/nodejs/node#release-keys + && for key in \ + 4ED778F539E3634C779C87C6D7062848A1AB005C \ + 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ + 74F12602B6F1C4E913FAA37AD3A89613643B6201 \ + 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ + 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ + C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ + C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \ + DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ + A48C2BEE680E841632CD4E44F07496B3EB3C1762 \ + 108F52B48DB57BB0CC439B2997B01419BD92F80A \ + B9E2F5981AA6E0CD28160D9FF13993A75599653C \ + ; do \ + gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ + gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ + gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ + && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ + && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ + && grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ + && tar -xf "node-v$NODE_VERSION.tar.xz" \ + && cd "node-v$NODE_VERSION" \ + && ./configure \ + && make -j$(getconf _NPROCESSORS_ONLN) V= \ + && make install \ + && apk del .build-deps-full \ + && cd .. \ + && rm -Rf "node-v$NODE_VERSION" \ + && rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \ + fi \ + && rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \ + && apk del .build-deps \ + # smoke tests + && node --version \ + && npm --version + +ENV YARN_VERSION 1.22.5 + +RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \ + && for key in \ + 6A010C5166006599AA17F08146C2130DFD2497F5 \ + ; do \ + gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ + gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ + gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ + done \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ + && curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \ + && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \ + && apk del .build-deps-yarn \ + # smoke test + && yarn --version + RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --virtual=build-dependencies \ - gcc \ - g++ \ - libffi-dev \ - python3-dev \ - git \ - curl \ - jq \ - make && \ - echo "**** install packages ****" && \ - apk add --no-cache \ - py3-pip \ - python3 && \ - echo "**** setup directories ****" && \ - mkdir /deem && \ - mkdir /deem/Music && \ - rm -R /config && \ - ln -sf /deem/.config/deemix /config && \ - ln -sf /downloads /deem/Music/deemix\ Music && \ - chown abc:abc /deem && \ - echo "**** clean up ****" && \ - rm -rf \ - /root/.cache \ - /tmp/* + echo "**** install build packages ****" && \ + apk add --no-cache --virtual=build-dependencies \ + git + +RUN git clone https://gitlab.com/RemixDev/deemix-gui.git --recursive && \ + rm -R /config && \ + mkdir /deemix-gui/server/music && \ + mkdir -p /deem/.config/deemix && \ + ln -sf /deemix-gui/server/music /downloads && \ + ln -sf /deem/.config/deemix /config + +WORKDIR /deemix-gui/server + +RUN yarn install COPY root/ / EXPOSE 6595 -VOLUME /downloads /config \ No newline at end of file +ENTRYPOINT [ "/init" ] \ No newline at end of file diff --git a/Dockerfile.arm32v7 b/Dockerfile.arm32v7 deleted file mode 100644 index b02f4a1..0000000 --- a/Dockerfile.arm32v7 +++ /dev/null @@ -1,53 +0,0 @@ -FROM alpine AS builder - -# Download QEMU, see https://github.com/docker/hub-feedback/issues/1261 -ENV QEMU_URL https://github.com/balena-io/qemu/releases/download/v5.2.0%2Bbalena4/qemu-5.2.0.balena4-arm.tar.gz -RUN apk add curl && curl -L ${QEMU_URL} | tar zxvf - -C . --strip-components 1 - - -FROM lsiobase/alpine:arm32v7-3.13 - -# Add QEMU -COPY --from=builder qemu-arm-static /usr/bin - -ARG BUILDDATE -ENV BUILDDATEENV=${BUILDDATE} - -LABEL \ - app.deemix.image.created="${BUILDDATE}" \ - app.deemix.image.url="https://gitlab.com/Bockiii/deemix-docker" \ - app.deemix.image.title="Docker image for Deemix" \ - app.deemix.image.description="Docker image for Deemix and the pyweb frontend" \ - maintainer="Bocki" - -RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --virtual=build-dependencies \ - gcc \ - g++ \ - libffi-dev \ - python3-dev \ - git \ - curl \ - jq \ - make && \ - echo "**** install packages ****" && \ - apk add --no-cache \ - py3-pip \ - python3 && \ - echo "**** setup directories ****" && \ - mkdir /deem && \ - mkdir /deem/Music && \ - rm -R /config && \ - ln -sf /deem/.config/deemix /config && \ - ln -sf /downloads /deem/Music/deemix\ Music && \ - chown abc:abc /deem && \ - echo "**** clean up ****" && \ - rm -rf \ - /root/.cache \ - /tmp/* - -COPY root/ / - -EXPOSE 6595 -VOLUME /downloads /config \ No newline at end of file diff --git a/Dockerfile.arm64v8 b/Dockerfile.arm64v8 deleted file mode 100644 index 986c115..0000000 --- a/Dockerfile.arm64v8 +++ /dev/null @@ -1,54 +0,0 @@ -FROM alpine AS builder - -# Download QEMU, see https://github.com/docker/hub-feedback/issues/1261 -ENV QEMU_URL https://github.com/balena-io/qemu/releases/download/v5.2.0%2Bbalena4/qemu-5.2.0.balena4-aarch64.tar.gz -RUN apk add curl && curl -L ${QEMU_URL} | tar zxvf - -C . --strip-components 1 - -FROM lsiobase/alpine:arm64v8-3.13 - -# Add QEMU -COPY --from=builder qemu-aarch64-static /usr/bin - -ARG BUILDDATE -ENV BUILDDATEENV=${BUILDDATE} - -LABEL \ - app.deemix.image.created="${BUILDDATE}" \ - app.deemix.image.url="https://gitlab.com/Bockiii/deemix-docker" \ - app.deemix.image.title="Docker image for Deemix" \ - app.deemix.image.description="Docker image for Deemix and the pyweb frontend" \ - maintainer="Bocki" - -EXPOSE 9666 - -RUN \ - echo "**** install build packages ****" && \ - apk add --no-cache --virtual=build-dependencies \ - gcc \ - g++ \ - libffi-dev \ - python3-dev \ - git \ - curl \ - jq \ - make && \ - echo "**** install packages ****" && \ - apk add --no-cache \ - py3-pip \ - python3 && \ - echo "**** setup directories ****" && \ - mkdir /deem && \ - mkdir /deem/Music && \ - rm -R /config && \ - ln -sf /deem/.config/deemix /config && \ - ln -sf /downloads /deem/Music/deemix\ Music && \ - chown abc:abc /deem && \ - echo "**** clean up ****" && \ - rm -rf \ - /root/.cache \ - /tmp/* - -COPY root/ / - -EXPOSE 6595 -VOLUME /downloads /config \ No newline at end of file diff --git a/root/etc/cont-init.d/10-fix_folders b/root/etc/cont-init.d/10-fix_folders new file mode 100644 index 0000000..fb5420b --- /dev/null +++ b/root/etc/cont-init.d/10-fix_folders @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bash + +# test write access to download and config folder and test internet connectivity +printf '[cont-init.d] Fixing Folder Permissions\n' + +chown abc:abc /deemix-gui/server +chown -R abc:abc /deem +chown -R abc:abc /config +chown -R abc:abc /deemix-gui/server/music \ No newline at end of file diff --git a/root/etc/cont-init.d/15-checks b/root/etc/cont-init.d/15-checks deleted file mode 100644 index ca196a9..0000000 --- a/root/etc/cont-init.d/15-checks +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/with-contenv bash - -# test write access to download and config folder and test internet connectivity -printf '[cont-init.d] Testing Access\n' && \ -printf '%-50s %2s %-5s \n' "[cont-init.d] Container Builddate" ":" "$BUILDDATEENV" && \ -if [ -w "/downloads" ]; then printf '%-50s %2s %-5s \n' "[cont-init.d] Download Folder Write Access" ":" "Success"; else printf '%-50s %2s %-5s \n' "[cont-init.d] Download Folder Write Access" ":" "Failure"; fi && \ -if [ -w "/config" ]; then printf '%-50s %2s %-5s \n' "[cont-init.d] Config Folder Write Access" ":" "Success"; else printf '%-50s %2s %-5s \n' "[cont-init.d] Config Folder Write Access" ":" "Failure"; fi && \ -until ping -c 1 www.deezer.com &> /dev/null; do printf '%-50s %2s %-5s \n' "[cont-init.d] Internet Access" ":" "Failure. Trying again in 5 seconds"; sleep 5; done -printf '%-50s %2s %-5s \n' "[cont-init.d] Internet Access" ":" "Success" \ No newline at end of file diff --git a/root/etc/cont-init.d/20-download b/root/etc/cont-init.d/20-download deleted file mode 100644 index 6fa941c..0000000 --- a/root/etc/cont-init.d/20-download +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/with-contenv bash - -# download and unpack -echo "[cont-init.d] Downloading and unpacking" - -if [ ! -f "/deemix/server.py" ]; then - echo "[cont-init.d] First start, downloading repo" - if [[ "${DEEZUI}" == "true" ]]; then - echo "[cont-init.d] Using Deezloader UI" - curl -L -o deemix_pyweb.zip http://gitlab.com/Bockiii/deemix-src/-/jobs/artifacts/master/download?job=dl_src - unzip -qq deemix_pyweb.zip -d / - rm -R /deemix/webui - mv /deezui /deemix/webui - touch /deemix/updated - else - echo "[cont-init.d] Using Deemix UI" - curl -L -o deemix_pyweb.zip http://gitlab.com/Bockiii/deemix-src/-/jobs/artifacts/master/download?job=dl_src - unzip -qq deemix_pyweb.zip -d / - rm -R /deezui - touch /deemix/updated - fi -fi diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config deleted file mode 100644 index fa51485..0000000 --- a/root/etc/cont-init.d/30-config +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/with-contenv bash - -# set home of the abc user -usermod -d /deem abc - -# permissions -echo "[cont-init.d] Setting permissions this may take some time" - -chown -R abc:abc \ - /deem/.config/ - -chown abc:abc \ - /downloads/ \ No newline at end of file diff --git a/root/etc/cont-init.d/40-install b/root/etc/cont-init.d/40-install deleted file mode 100644 index 58bb974..0000000 --- a/root/etc/cont-init.d/40-install +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/with-contenv bash - -# install deemix - -if [ -f "/deemix/updated" ]; then - echo "[cont-init.d] Installing" - cd /deemix - pip3 install -U -r server-requirements.txt --quiet --disable-pip-version-check - rm /deemix/updated - echo "[cont-init.d] Installation done" -fi - -# check for arl environment variable. if it is set, create the arl file. -# if the arl was previously set but is out of date, update the file with the arl from the env variable - -if [ ${#ARL} -gt 10 ]; then - # this file might not exist; happens when the users runs for the first time - OLDARL=$(cat /config/.arl 2>/dev/null || echo 0) # ignore if the file doesn't exist - if [ "$ARL" != "$OLDARL" ]; then - echo "[cont-init.d] !!! ARL from environment variable does not match current ARL. Using environment variable. !!!" - echo "[cont-init.d] !!! Please update your ARL in the variable instead of the webinterface or remove the ARL from the container call. !!!" - printf $ARL > /config/.arl - fi -fi - -# Fix misconfigured download locations. The container's download map is always /downloads. -if [ -f "/config/config.json" ]; then - jq '.downloadLocation = "/downloads"' /config/config.json > tmp.$$.json && mv tmp.$$.json /config/config.json - chown abc:abc /config/config.json -fi \ No newline at end of file diff --git a/root/etc/services.d/deemix/run b/root/etc/services.d/deemix/run index 7b3f9f7..9189611 100644 --- a/root/etc/services.d/deemix/run +++ b/root/etc/services.d/deemix/run @@ -1,26 +1,13 @@ #!/usr/bin/with-contenv bash +printf '%-50s %2s %-5s \n' "[services.d] Package Build Date" ":" "$(cat /deemix/packagedate)" + UMASK_SET=${UMASK_SET:-022} umask "$UMASK_SET" -cd /deemix +cd /deemix-gui/server HOME=/deem -printf '%-50s %2s %-5s \n' "[cont-init.d] Package Build Date" ":" "$(cat /deemix/packagedate)" - -if [ ! -z ${INTPORT} ]; then - port=$INTPORT -else - port=6595 -fi - -if [ -f "/config/.arl" ]; then - echo "[services.d] Starting with ARL" - exec \ - s6-setuidgid abc python3 /deemix/server.py $port --serverwide-arl --host 0.0.0.0 -else - echo "[services.d] Starting without ARL" - exec \ - s6-setuidgid abc python3 /deemix/server.py $port --host 0.0.0.0 -fi +echo "[services.d] Starting Deemix" +s6-setuidgid abc yarn start \ No newline at end of file