tubearchivist/Dockerfile

79 lines
2.3 KiB
Docker
Raw Normal View History

# multi stage to build tube archivist
# first stage to build python wheel, copy into final image
2021-09-05 17:10:14 +00:00
# First stage to build python wheel
2022-09-17 03:53:43 +00:00
FROM python:3.10.7-slim-bullseye AS builder
ARG TARGETPLATFORM
2021-09-05 17:10:14 +00:00
RUN apt-get update
RUN apt-get install -y --no-install-recommends build-essential gcc libldap2-dev libsasl2-dev libssl-dev
# install requirements
COPY ./tubearchivist/requirements.txt /requirements.txt
RUN pip install --user -r requirements.txt
# build final image
2022-09-17 03:53:43 +00:00
FROM python:3.10.7-slim-bullseye as tubearchivist
ARG TARGETPLATFORM
ARG INSTALL_DEBUG
ENV PYTHONUNBUFFERED 1
# copy build requirements
COPY --from=builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
# install distro packages needed
RUN apt-get clean && apt-get -y update && apt-get -y install --no-install-recommends \
nginx \
atomicparsley \
curl \
xz-utils && rm -rf /var/lib/apt/lists/*
# get newest patched ffmpeg and ffprobe builds for amd64 fall back to repo ffmpeg for arm64
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ] ; then \
curl -s https://api.github.com/repos/yt-dlp/FFmpeg-Builds/releases/latest \
| grep browser_download_url \
| grep ".*master.*linux64.*tar.xz" \
| cut -d '"' -f 4 \
| xargs curl -L --output ffmpeg.tar.xz && \
tar -xf ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffmpeg" && \
tar -xf ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffprobe" && \
rm ffmpeg.tar.xz \
; elif [ "$TARGETPLATFORM" = "linux/arm64" ] ; then \
apt-get -y update && apt-get -y install --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/* \
; fi
# install debug tools for testing environment
RUN if [ "$INSTALL_DEBUG" ] ; then \
apt-get -y update && apt-get -y install --no-install-recommends \
vim htop bmon net-tools iputils-ping procps \
&& pip install --user ipython \
; fi
2021-09-05 17:10:14 +00:00
# make folders
RUN mkdir /cache /youtube /app
2021-09-05 17:10:14 +00:00
# copy config files
COPY docker_assets/nginx.conf /etc/nginx/sites-available/default
RUN sed -i 's/^user www\-data\;$/user root\;/' /etc/nginx/nginx.conf
2021-09-05 17:10:14 +00:00
# copy application into container
COPY ./tubearchivist /app
2022-01-26 13:05:52 +00:00
COPY ./docker_assets/run.sh /app
COPY ./docker_assets/uwsgi.ini /app
2021-09-05 17:10:14 +00:00
# volumes
VOLUME /cache
VOLUME /youtube
# start
WORKDIR /app
2021-09-16 08:36:14 +00:00
EXPOSE 8000
2021-09-05 17:10:14 +00:00
RUN chmod +x ./run.sh
CMD ["./run.sh"]