-
Notifications
You must be signed in to change notification settings - Fork 59
/
Dockerfile
62 lines (43 loc) · 1.98 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
ARG PYTHON_VERSION=3.8
ARG CURL_IMPERSONATE_VERSION=0.5-chrome
FROM lwthiker/curl-impersonate:${CURL_IMPERSONATE_VERSION} as curl
# Builder
FROM python:${PYTHON_VERSION}-alpine as builder
RUN apk add --update git build-base libffi-dev curl-dev
WORKDIR /root
COPY --from=curl /usr/local/bin/curl_* /usr/local/bin/
COPY --from=curl /usr/local/lib/ /usr/local/lib/
# Install requirements
COPY requirements.txt /root
RUN pip install --prefix="/install" --no-warn-script-location -r requirements.txt
# Install FFmpeg
ARG TARGETARCH
ARG FFMPEG_VERSION=4.2.2
RUN echo "Download from https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-${FFMPEG_VERSION}-${TARGETARCH}-static.tar.xz" && \
wget https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-${FFMPEG_VERSION}-${TARGETARCH}-static.tar.xz -O ffmpeg.tar.xz && \
tar Jxvf ./ffmpeg.tar.xz && \
cp ./ffmpeg-${FFMPEG_VERSION}-${TARGETARCH}-static/ffmpeg /usr/local/bin/
# Runtime
FROM python:${PYTHON_VERSION}-alpine
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
RUN apk add --no-cache curl
# Install FFmpeg
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/
# cURL Impersonate libraries
COPY --from=builder /usr/local/bin/curl_* /usr/local/bin/
COPY --from=builder /usr/local/lib/libcurl-* /usr/local/lib/
# Copy pip requirements
COPY --from=builder /install /usr/local
# Copy CA certificates for curl_cffi, can be removed once v0.6 is officially released
RUN PYTHON_LIB_PATH="$(python -c 'import site; print(site.getsitepackages()[0])')" &&\
CA_FILE="$(python -c 'import certifi; print(certifi.where())')" && \
cp "$CA_FILE" "$PYTHON_LIB_PATH"/curl_cffi/
WORKDIR /app
COPY nazurin ./nazurin
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
CMD ["python", "-m", "nazurin"]