2020-11-24 07:18:39 +00:00
|
|
|
FROM debian:buster-slim
|
|
|
|
|
2020-11-24 08:07:10 +00:00
|
|
|
ARG DEBIAN_FRONTEND="noninteractive"
|
|
|
|
|
2020-11-24 07:18:39 +00:00
|
|
|
# Third party software versions
|
2020-11-24 08:07:10 +00:00
|
|
|
ARG FFMPEG_VERSION="4.3.1"
|
|
|
|
ENV FFMPEG_EXPECTED_MD5="ee235393ec7778279144ee6cbdd9eb64"
|
|
|
|
ENV FFMPEG_TARBALL="https://johnvansickle.com/ffmpeg/releases/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar.xz"
|
2020-11-24 07:18:39 +00:00
|
|
|
|
|
|
|
# Install third party software
|
|
|
|
RUN set -x && \
|
|
|
|
# Install required distro packages
|
|
|
|
apt-get update && \
|
2020-11-26 03:03:55 +00:00
|
|
|
apt-get -y --no-install-recommends install curl xz-utils ca-certificates binutils && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Install ffmpeg
|
|
|
|
curl -L ${FFMPEG_TARBALL} --output /tmp/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar.xz && \
|
|
|
|
echo "${FFMPEG_EXPECTED_MD5} tmp/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar.xz" | md5sum -c - && \
|
|
|
|
xz --decompress /tmp/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar.xz && \
|
|
|
|
tar -xvf /tmp/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar -C /tmp && \
|
|
|
|
ls -lat /tmp/ffmpeg-4.3.1-amd64-static && \
|
|
|
|
install -v -s -g root -o root -m 0755 -s /tmp/ffmpeg-${FFMPEG_VERSION}-amd64-static/ffmpeg -t /usr/local/bin && \
|
|
|
|
# Clean up
|
|
|
|
rm -rf /tmp/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar && \
|
|
|
|
rm -rf /tmp/ffmpeg-${FFMPEG_VERSION}-amd64-static && \
|
|
|
|
apt-get -y autoremove --purge curl xz-utils binutils
|
|
|
|
|
|
|
|
# Defaults
|
2020-11-24 08:07:10 +00:00
|
|
|
ARG default_uid="10000"
|
|
|
|
ARG default_gid="10000"
|
2020-11-24 07:18:39 +00:00
|
|
|
|
|
|
|
# Copy app
|
|
|
|
COPY app /app
|
|
|
|
COPY app/tubesync/local_settings.py.container /app/tubesync/local_settings.py
|
|
|
|
|
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-11-24 07:18:39 +00:00
|
|
|
# Add Pipfiles
|
|
|
|
COPY Pipfile /app/Pipfile
|
|
|
|
COPY Pipfile.lock /app/Pipfile.lock
|
|
|
|
|
|
|
|
# Switch workdir to the the app
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Set up the app
|
2020-11-24 08:07:10 +00:00
|
|
|
ENV UID="${default_uid}"
|
|
|
|
ENV GID="${default_gid}"
|
2020-11-24 07:18:39 +00:00
|
|
|
RUN set -x && \
|
|
|
|
# Install required distro packages
|
2020-11-26 03:03:55 +00:00
|
|
|
apt-get -y --no-install-recommends install python3 python3-setuptools python3-pip python3-dev gcc make && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Install wheel which is required for pipenv
|
|
|
|
pip3 --disable-pip-version-check install wheel && \
|
|
|
|
# Then install pipenv
|
|
|
|
pip3 --disable-pip-version-check install pipenv && \
|
|
|
|
# Create a 'www' user which the workers drop to
|
|
|
|
groupadd -g ${GID} www && \
|
2020-11-26 03:03:55 +00:00
|
|
|
useradd -M -d /app -s /bin/false -u ${UID} -g www www && \
|
2020-11-24 07:18:39 +00:00
|
|
|
# Install non-distro packages
|
|
|
|
pipenv install --system && \
|
|
|
|
# Make absolutely sure we didn't accidentally bundle a SQLite dev database
|
|
|
|
rm -rf /app/db.sqlite3 && \
|
|
|
|
# Create config, downloads and run dirs we can write to
|
|
|
|
mkdir -p /run/www && \
|
|
|
|
chown -R www:www /run/www && \
|
|
|
|
chmod -R 0700 /run/www && \
|
2020-11-28 06:03:20 +00:00
|
|
|
mkdir -p /config/media && \
|
2020-11-24 07:18:39 +00:00
|
|
|
chown -R www:www /config && \
|
|
|
|
chmod -R 0755 /config && \
|
2020-11-28 06:03:20 +00:00
|
|
|
mkdir -p /downloads/{audio,video} && \
|
2020-11-24 07:18:39 +00:00
|
|
|
chown -R www:www /downloads && \
|
|
|
|
chmod -R 0755 /downloads && \
|
|
|
|
# Reset permissions
|
|
|
|
mkdir -p /app/static && \
|
|
|
|
chown -R root:www /app && \
|
|
|
|
chown -R www:www /app/common/static && \
|
|
|
|
chown -R www:www /app/static && \
|
|
|
|
chmod -R 0750 /app && \
|
|
|
|
find /app -type f -exec chmod 640 {} \; && \
|
|
|
|
chmod 0750 /app/entrypoint.sh && \
|
|
|
|
# Clean up
|
|
|
|
rm /app/Pipfile && \
|
|
|
|
rm /app/Pipfile.lock && \
|
|
|
|
pipenv --clear && \
|
|
|
|
pip3 --disable-pip-version-check uninstall -y pipenv wheel virtualenv && \
|
2020-11-24 08:07:10 +00:00
|
|
|
apt-get -y autoremove --purge python3-pip python3-dev gcc make && \
|
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
|
|
|
|
|
|
|
|
# Create a healthcheck
|
|
|
|
HEALTHCHECK --interval=1m --timeout=10s CMD /app/healthcheck.py http://127.0.0.1:8080/healthcheck
|
|
|
|
|
|
|
|
# Drop to the www user
|
|
|
|
USER www
|
|
|
|
|
|
|
|
# ENVS and ports
|
|
|
|
ENV PYTHONPATH "/app:${PYTHONPATH}"
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
# Entrypoint
|
|
|
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
|
|
|
|
|
|
|
# Run gunicorn
|
2020-11-29 06:14:10 +00:00
|
|
|
CMD ["/usr/local/bin/gunicorn", "-c", "/app/tubesync/gunicorn.py", "--capture-output", "tubesync.wsgi:application"]
|