2020-11-24 07:18:39 +00:00
|
|
|
FROM debian:buster-slim
|
|
|
|
|
2020-12-13 05:13:30 +00:00
|
|
|
ARG ARCH="amd64"
|
2021-03-07 06:12:40 +00:00
|
|
|
ARG S6_VERSION="2.2.0.3"
|
2021-03-07 06:38:35 +00:00
|
|
|
ARG FFMPEG_VERSION="4.3.2"
|
2020-12-13 05:13:30 +00:00
|
|
|
|
|
|
|
ENV DEBIAN_FRONTEND="noninteractive" \
|
|
|
|
HOME="/root" \
|
|
|
|
LANGUAGE="en_US.UTF-8" \
|
|
|
|
LANG="en_US.UTF-8" \
|
|
|
|
LC_ALL="en_US.UTF-8" \
|
|
|
|
TERM="xterm" \
|
2021-03-07 06:12:40 +00:00
|
|
|
S6_EXPECTED_SHA256="a7076cf205b331e9f8479bbb09d9df77dbb5cd8f7d12e9b74920902e0c16dd98" \
|
2020-12-13 05:13:30 +00:00
|
|
|
S6_DOWNLOAD="https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-${ARCH}.tar.gz" \
|
2021-03-07 06:38:35 +00:00
|
|
|
FFMPEG_EXPECTED_SHA256="34bffcd0b58695e3ee5eba2573b37f06cb5088050733ca96265815f58bd61d35" \
|
2020-12-18 00:28:40 +00:00
|
|
|
FFMPEG_DOWNLOAD="https://tubesync.sfo2.digitaloceanspaces.com/ffmpeg-${FFMPEG_VERSION}-${ARCH}-static.tar.xz"
|
|
|
|
|
2020-11-24 07:18:39 +00:00
|
|
|
|
|
|
|
# Install third party software
|
|
|
|
RUN set -x && \
|
|
|
|
apt-get update && \
|
2020-12-13 05:13:30 +00:00
|
|
|
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
|
2020-11-26 03:03:55 +00:00
|
|
|
apt-get -y --no-install-recommends install curl xz-utils ca-certificates binutils && \
|
2020-12-13 05:13:30 +00:00
|
|
|
# Install s6
|
|
|
|
curl -L ${S6_DOWNLOAD} --output /tmp/s6-overlay-${ARCH}.tar.gz && \
|
|
|
|
sha256sum /tmp/s6-overlay-${ARCH}.tar.gz && \
|
|
|
|
echo "${S6_EXPECTED_SHA256} /tmp/s6-overlay-${ARCH}.tar.gz" | sha256sum -c - && \
|
|
|
|
tar xzf /tmp/s6-overlay-${ARCH}.tar.gz -C / && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Install ffmpeg
|
2020-12-13 05:13:30 +00:00
|
|
|
curl -L ${FFMPEG_DOWNLOAD} --output /tmp/ffmpeg-${ARCH}-static.tar.xz && \
|
|
|
|
echo "${FFMPEG_EXPECTED_SHA256} /tmp/ffmpeg-${ARCH}-static.tar.xz" | sha256sum -c - && \
|
|
|
|
xz --decompress /tmp/ffmpeg-${ARCH}-static.tar.xz && \
|
|
|
|
tar -xvf /tmp/ffmpeg-${ARCH}-static.tar -C /tmp && \
|
|
|
|
install -v -s -g root -o root -m 0755 -s /tmp/ffmpeg-${FFMPEG_VERSION}-${ARCH}-static/ffmpeg -t /usr/local/bin && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Clean up
|
2020-12-13 05:13:30 +00:00
|
|
|
rm -rf /tmp/s6-overlay-${ARCH}.tar.gz && \
|
|
|
|
rm -rf /tmp/ffmpeg-${ARCH}-static.tar && \
|
|
|
|
rm -rf /tmp/ffmpeg-${FFMPEG_VERSION}-${ARCH}-static && \
|
2020-11-24 07:18:39 +00:00
|
|
|
apt-get -y autoremove --purge curl xz-utils binutils
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2020-11-27 06:50:15 +00:00
|
|
|
# Append container bundled software versions
|
|
|
|
RUN echo "ffmpeg_version = '${FFMPEG_VERSION}-static'" >> /app/common/third_party_versions.py
|
|
|
|
|
2020-12-13 05:13:30 +00:00
|
|
|
# Add Pipfile
|
2020-11-24 07:18:39 +00:00
|
|
|
COPY Pipfile /app/Pipfile
|
|
|
|
COPY Pipfile.lock /app/Pipfile.lock
|
|
|
|
|
|
|
|
# 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-06-19 05:36:39 +00:00
|
|
|
apt-get -y --no-install-recommends install python3 python3-setuptools python3-pip python3-dev gcc make default-libmysqlclient-dev libmariadb3 postgresql-common libpq-dev && \
|
2020-12-13 05:13:30 +00:00
|
|
|
# Install pipenv
|
2020-11-24 07:18:39 +00:00
|
|
|
pip3 --disable-pip-version-check install 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
|
2020-12-13 05:13:30 +00:00
|
|
|
pipenv install --system && \
|
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 && \
|
|
|
|
rm /app/Pipfile.lock && \
|
|
|
|
pipenv --clear && \
|
|
|
|
pip3 --disable-pip-version-check uninstall -y pipenv wheel virtualenv && \
|
2021-06-19 05:36:39 +00:00
|
|
|
apt-get -y autoremove --purge python3-pip python3-dev gcc make default-libmysqlclient-dev postgresql-common libpq-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 && \
|
|
|
|
chmod 0700 /root
|
|
|
|
|
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}"
|
|
|
|
EXPOSE 8080
|
|
|
|
|
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"]
|