2022-04-10 15:43:00 +00:00
|
|
|
# multi stage to build tube archivist
|
2024-04-22 15:49:26 +00:00
|
|
|
# build python wheel, download and extract ffmpeg, copy into final image
|
2021-09-05 17:10:14 +00:00
|
|
|
|
2022-04-10 15:43:00 +00:00
|
|
|
|
|
|
|
# First stage to build python wheel
|
2024-05-15 17:54:16 +00:00
|
|
|
FROM python:3.11.8-slim-bookworm AS builder
|
2021-09-05 17:10:14 +00:00
|
|
|
|
2022-10-25 04:22:32 +00:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
2023-10-03 13:49:57 +00:00
|
|
|
build-essential gcc libldap2-dev libsasl2-dev libssl-dev git
|
2021-09-30 15:01:30 +00:00
|
|
|
|
2022-04-11 10:58:19 +00:00
|
|
|
# install requirements
|
|
|
|
COPY ./tubearchivist/requirements.txt /requirements.txt
|
|
|
|
RUN pip install --user -r requirements.txt
|
|
|
|
|
2024-04-22 15:49:26 +00:00
|
|
|
# build ffmpeg
|
2024-05-15 17:54:16 +00:00
|
|
|
FROM python:3.11.8-slim-bookworm as ffmpeg-builder
|
2024-05-26 21:37:26 +00:00
|
|
|
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
|
2024-04-22 15:49:26 +00:00
|
|
|
COPY docker_assets/ffmpeg_download.py ffmpeg_download.py
|
|
|
|
RUN python ffmpeg_download.py $TARGETPLATFORM
|
|
|
|
|
2022-04-10 15:43:00 +00:00
|
|
|
# build final image
|
2024-05-15 17:54:16 +00:00
|
|
|
FROM python:3.11.8-slim-bookworm as tubearchivist
|
2022-04-10 15:43:00 +00:00
|
|
|
|
|
|
|
ARG INSTALL_DEBUG
|
|
|
|
|
|
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
|
|
|
|
# copy build requirements
|
|
|
|
COPY --from=builder /root/.local /root/.local
|
|
|
|
ENV PATH=/root/.local/bin:$PATH
|
|
|
|
|
2024-04-22 15:49:26 +00:00
|
|
|
# copy ffmpeg
|
|
|
|
COPY --from=ffmpeg-builder ./ffmpeg/ffmpeg /usr/bin/ffmpeg
|
|
|
|
COPY --from=ffmpeg-builder ./ffprobe/ffprobe /usr/bin/ffprobe
|
|
|
|
|
2022-04-10 15:43:00 +00:00
|
|
|
# install distro packages needed
|
|
|
|
RUN apt-get clean && apt-get -y update && apt-get -y install --no-install-recommends \
|
|
|
|
nginx \
|
|
|
|
atomicparsley \
|
2024-04-22 15:49:26 +00:00
|
|
|
curl && rm -rf /var/lib/apt/lists/*
|
2022-04-10 15:43:00 +00:00
|
|
|
|
2022-03-24 12:54:47 +00:00
|
|
|
# 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 \
|
2024-05-21 10:18:25 +00:00
|
|
|
&& pip install --user ipython pytest pytest-django \
|
2022-03-24 12:54:47 +00:00
|
|
|
; fi
|
|
|
|
|
2021-09-05 17:10:14 +00:00
|
|
|
# make folders
|
2022-07-16 14:54:39 +00:00
|
|
|
RUN mkdir /cache /youtube /app
|
2021-09-05 17:10:14 +00:00
|
|
|
|
2022-01-01 15:16:34 +00:00
|
|
|
# copy config files
|
2022-04-01 04:43:24 +00:00
|
|
|
COPY docker_assets/nginx.conf /etc/nginx/sites-available/default
|
2022-07-16 14:54:39 +00:00
|
|
|
RUN sed -i 's/^user www\-data\;$/user root\;/' /etc/nginx/nginx.conf
|
2022-01-01 15:16:34 +00:00
|
|
|
|
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"]
|