2021-10-15 09:18:03 +00:00
|
|
|
FROM debian:bullseye-slim
|
2020-11-24 07:18:39 +00:00
|
|
|
|
2022-06-07 16:04:34 +00:00
|
|
|
ARG TARGETPLATFORM
|
2023-01-18 07:39:23 +00:00
|
|
|
ARG S6_VERSION="3.1.2.1"
|
2023-05-03 16:03:16 +00:00
|
|
|
ARG FFMPEG_DATE="autobuild-2023-05-03-12-37"
|
|
|
|
ARG FFMPEG_VERSION="110465-g0e580806d8"
|
2020-12-13 05:13:30 +00:00
|
|
|
|
|
|
|
ENV DEBIAN_FRONTEND="noninteractive" \
|
2022-06-07 16:04:34 +00:00
|
|
|
HOME="/root" \
|
|
|
|
LANGUAGE="en_US.UTF-8" \
|
|
|
|
LANG="en_US.UTF-8" \
|
|
|
|
LC_ALL="en_US.UTF-8" \
|
2023-01-19 00:38:01 +00:00
|
|
|
TERM="xterm" \
|
2023-01-19 01:57:09 +00:00
|
|
|
S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0"
|
2020-11-24 07:18:39 +00:00
|
|
|
|
|
|
|
# Install third party software
|
2022-06-07 16:33:03 +00:00
|
|
|
RUN export ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \
|
|
|
|
"linux/amd64") echo "amd64" ;; \
|
|
|
|
"linux/arm64") echo "aarch64" ;; \
|
|
|
|
*) echo "" ;; esac) && \
|
2023-01-18 07:39:23 +00:00
|
|
|
export S6_ARCH_EXPECTED_SHA256=$(case ${TARGETPLATFORM:-linux/amd64} in \
|
|
|
|
"linux/amd64") echo "6019b6b06cfdbb1d1cd572d46b9b158a4904fd19ca59d374de4ddaaa6a3727d5" ;; \
|
|
|
|
"linux/arm64") echo "e73f9a021b64f88278830742149c14ef8a52331102881ba025bf32a66a0e7c78" ;; \
|
2022-06-07 16:33:03 +00:00
|
|
|
*) echo "" ;; esac) && \
|
2023-01-18 07:39:23 +00:00
|
|
|
export S6_DOWNLOAD_ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \
|
|
|
|
"linux/amd64") echo "https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-x86_64.tar.xz" ;; \
|
|
|
|
"linux/arm64") echo "https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-aarch64.tar.xz" ;; \
|
2022-06-07 16:49:29 +00:00
|
|
|
*) echo "" ;; esac) && \
|
2022-10-13 10:25:06 +00:00
|
|
|
export FFMPEG_EXPECTED_SHA256=$(case ${TARGETPLATFORM:-linux/amd64} in \
|
2023-05-03 16:03:16 +00:00
|
|
|
"linux/amd64") echo "cfc81468bc62706639045c13c54a7074ffda7aa0a6fa774505de93c602c298e9" ;; \
|
|
|
|
"linux/arm64") echo "d9a0244c8d239b8409d84f4b8a465842b611855e8b409a527b54c8c748efc27e" ;; \
|
2022-10-13 10:25:06 +00:00
|
|
|
*) echo "" ;; esac) && \
|
|
|
|
export FFMPEG_DOWNLOAD=$(case ${TARGETPLATFORM:-linux/amd64} in \
|
2023-01-18 07:39:23 +00:00
|
|
|
"linux/amd64") echo "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/${FFMPEG_DATE}/ffmpeg-N-${FFMPEG_VERSION}-linux64-gpl.tar.xz" ;; \
|
|
|
|
"linux/arm64") echo "https://github.com/yt-dlp/FFmpeg-Builds/releases/download/${FFMPEG_DATE}/ffmpeg-N-${FFMPEG_VERSION}-linuxarm64-gpl.tar.xz" ;; \
|
2022-10-13 10:25:06 +00:00
|
|
|
*) echo "" ;; esac) && \
|
2023-01-18 07:39:23 +00:00
|
|
|
export S6_NOARCH_EXPECTED_SHA256="cee89d3eeabdfe15239b2c5c3581d9352d2197d4fd23bba3f1e64bf916ccf496" && \
|
|
|
|
export S6_DOWNLOAD_NOARCH="https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-noarch.tar.xz" && \
|
2022-06-07 16:41:11 +00:00
|
|
|
echo "Building for arch: ${ARCH}|${ARCH44}, downloading S6 from: ${S6_DOWNLOAD}}, expecting S6 SHA256: ${S6_EXPECTED_SHA256}" && \
|
2022-06-07 16:33:03 +00:00
|
|
|
set -x && \
|
2022-06-07 16:04:34 +00:00
|
|
|
apt-get update && \
|
|
|
|
apt-get -y --no-install-recommends install locales && \
|
|
|
|
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
|
|
|
|
locale-gen en_US.UTF-8 && \
|
|
|
|
# Install required distro packages
|
2022-10-13 10:25:06 +00:00
|
|
|
apt-get -y --no-install-recommends install curl ca-certificates binutils xz-utils && \
|
2022-06-07 16:04:34 +00:00
|
|
|
# Install s6
|
2023-01-18 07:39:23 +00:00
|
|
|
curl -L ${S6_DOWNLOAD_NOARCH} --output /tmp/s6-overlay-noarch.tar.xz && \
|
|
|
|
echo "${S6_NOARCH_EXPECTED_SHA256} /tmp/s6-overlay-noarch.tar.xz" | sha256sum -c - && \
|
|
|
|
tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && \
|
|
|
|
curl -L ${S6_DOWNLOAD_ARCH} --output /tmp/s6-overlay-${ARCH}.tar.xz && \
|
|
|
|
echo "${S6_ARCH_EXPECTED_SHA256} /tmp/s6-overlay-${ARCH}.tar.xz" | sha256sum -c - && \
|
|
|
|
tar -C / -Jxpf /tmp/s6-overlay-${ARCH}.tar.xz && \
|
|
|
|
# Install ffmpeg
|
2022-10-13 10:25:06 +00:00
|
|
|
echo "Building for arch: ${ARCH}|${ARCH44}, downloading FFMPEG from: ${FFMPEG_DOWNLOAD}, expecting FFMPEG SHA256: ${FFMPEG_EXPECTED_SHA256}" && \
|
|
|
|
curl -L ${FFMPEG_DOWNLOAD} --output /tmp/ffmpeg-${ARCH}.tar.xz && \
|
|
|
|
sha256sum /tmp/ffmpeg-${ARCH}.tar.xz && \
|
|
|
|
echo "${FFMPEG_EXPECTED_SHA256} /tmp/ffmpeg-${ARCH}.tar.xz" | sha256sum -c - && \
|
|
|
|
tar -xf /tmp/ffmpeg-${ARCH}.tar.xz --strip-components=2 --no-anchored -C /usr/local/bin/ "ffmpeg" && \
|
|
|
|
tar -xf /tmp/ffmpeg-${ARCH}.tar.xz --strip-components=2 --no-anchored -C /usr/local/bin/ "ffprobe" && \
|
2022-06-07 16:04:34 +00:00
|
|
|
# Clean up
|
|
|
|
rm -rf /tmp/s6-overlay-${ARCH}.tar.gz && \
|
2022-10-13 10:25:06 +00:00
|
|
|
rm -rf /tmp/ffmpeg-${ARCH}.tar.xz && \
|
|
|
|
apt-get -y autoremove --purge curl binutils xz-utils
|
2020-11-24 07:18:39 +00:00
|
|
|
|
|
|
|
# Copy app
|
2020-12-09 16:40:06 +00:00
|
|
|
COPY tubesync /app
|
|
|
|
COPY tubesync/tubesync/local_settings.py.container /app/tubesync/local_settings.py
|
2020-11-24 07:18:39 +00:00
|
|
|
|
2022-06-07 17:51:48 +00:00
|
|
|
# Copy over pip.conf to use piwheels
|
|
|
|
COPY pip.conf /etc/pip.conf
|
|
|
|
|
2020-12-13 05:13:30 +00:00
|
|
|
# Add Pipfile
|
2020-11-24 07:18:39 +00:00
|
|
|
COPY Pipfile /app/Pipfile
|
|
|
|
|
|
|
|
# Switch workdir to the the app
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Set up the app
|
|
|
|
RUN set -x && \
|
2021-04-04 14:31:50 +00:00
|
|
|
apt-get update && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Install required distro packages
|
2020-12-13 05:13:30 +00:00
|
|
|
apt-get -y install nginx-light && \
|
2021-09-03 04:46:13 +00:00
|
|
|
apt-get -y --no-install-recommends install \
|
2022-06-07 16:04:34 +00:00
|
|
|
python3 \
|
|
|
|
python3-setuptools \
|
|
|
|
python3-pip \
|
|
|
|
python3-dev \
|
|
|
|
gcc \
|
2022-06-07 17:51:48 +00:00
|
|
|
g++ \
|
2022-06-07 16:04:34 +00:00
|
|
|
make \
|
|
|
|
default-libmysqlclient-dev \
|
|
|
|
libmariadb3 \
|
|
|
|
postgresql-common \
|
|
|
|
libpq-dev \
|
|
|
|
libpq5 \
|
|
|
|
libjpeg62-turbo \
|
|
|
|
libwebp6 \
|
|
|
|
libjpeg-dev \
|
|
|
|
zlib1g-dev \
|
|
|
|
libwebp-dev \
|
|
|
|
redis-server && \
|
2020-12-13 05:13:30 +00:00
|
|
|
# Install pipenv
|
2021-09-03 04:46:13 +00:00
|
|
|
pip3 --disable-pip-version-check install wheel pipenv && \
|
2020-12-13 05:13:30 +00:00
|
|
|
# Create a 'app' user which the application will run as
|
|
|
|
groupadd app && \
|
|
|
|
useradd -M -d /app -s /bin/false -g app app && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Install non-distro packages
|
2023-01-18 07:39:23 +00:00
|
|
|
pipenv install --system --skip-lock && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Make absolutely sure we didn't accidentally bundle a SQLite dev database
|
|
|
|
rm -rf /app/db.sqlite3 && \
|
2020-12-13 05:13:30 +00:00
|
|
|
# Run any required app commands
|
|
|
|
/usr/bin/python3 /app/manage.py compilescss && \
|
|
|
|
/usr/bin/python3 /app/manage.py collectstatic --no-input --link && \
|
|
|
|
# Create config, downloads and run dirs
|
|
|
|
mkdir -p /run/app && \
|
2020-11-28 06:03:20 +00:00
|
|
|
mkdir -p /config/media && \
|
2020-12-13 05:13:30 +00:00
|
|
|
mkdir -p /downloads/audio && \
|
|
|
|
mkdir -p /downloads/video && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Clean up
|
|
|
|
rm /app/Pipfile && \
|
|
|
|
pipenv --clear && \
|
|
|
|
pip3 --disable-pip-version-check uninstall -y pipenv wheel virtualenv && \
|
2021-09-03 04:46:13 +00:00
|
|
|
apt-get -y autoremove --purge \
|
2022-06-07 16:04:34 +00:00
|
|
|
python3-pip \
|
|
|
|
python3-dev \
|
|
|
|
gcc \
|
2022-06-07 17:51:48 +00:00
|
|
|
g++ \
|
2022-06-07 16:04:34 +00:00
|
|
|
make \
|
|
|
|
default-libmysqlclient-dev \
|
|
|
|
postgresql-common \
|
|
|
|
libpq-dev \
|
|
|
|
libjpeg-dev \
|
|
|
|
zlib1g-dev \
|
|
|
|
libwebp-dev && \
|
2020-11-24 07:18:39 +00:00
|
|
|
apt-get -y autoremove && \
|
|
|
|
apt-get -y autoclean && \
|
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
rm -rf /var/cache/apt/* && \
|
|
|
|
rm -rf /tmp/* && \
|
|
|
|
# Pipenv leaves a bunch of stuff in /root, as we're not using it recreate it
|
|
|
|
rm -rf /root && \
|
|
|
|
mkdir -p /root && \
|
|
|
|
chown root:root /root && \
|
2023-01-18 07:39:23 +00:00
|
|
|
chmod 0755 /root
|
2020-11-24 07:18:39 +00:00
|
|
|
|
2021-10-15 09:35:28 +00:00
|
|
|
# Append software versions
|
|
|
|
RUN set -x && \
|
2022-10-13 10:25:06 +00:00
|
|
|
FFMPEG_VERSION=$(/usr/local/bin/ffmpeg -version | head -n 1 | awk '{ print $3 }') && \
|
2021-10-15 09:35:28 +00:00
|
|
|
echo "ffmpeg_version = '${FFMPEG_VERSION}'" >> /app/common/third_party_versions.py
|
|
|
|
|
2020-12-13 05:13:30 +00:00
|
|
|
# Copy root
|
|
|
|
COPY config/root /
|
|
|
|
|
2020-11-24 07:18:39 +00:00
|
|
|
# Create a healthcheck
|
|
|
|
HEALTHCHECK --interval=1m --timeout=10s CMD /app/healthcheck.py http://127.0.0.1:8080/healthcheck
|
|
|
|
|
|
|
|
# ENVS and ports
|
|
|
|
ENV PYTHONPATH "/app:${PYTHONPATH}"
|
2022-01-17 01:42:08 +00:00
|
|
|
EXPOSE 4848
|
2020-11-24 07:18:39 +00:00
|
|
|
|
2020-12-13 05:13:30 +00:00
|
|
|
# Volumes
|
|
|
|
VOLUME ["/config", "/downloads"]
|
2020-11-24 07:18:39 +00:00
|
|
|
|
2020-12-13 05:13:30 +00:00
|
|
|
# Entrypoint, start s6 init
|
|
|
|
ENTRYPOINT ["/init"]
|