Fixed dockerfile

This commit is contained in:
Benjamin Sherriff
2023-10-06 19:39:14 -04:00
parent fd0226f420
commit cb1fd182f1

View File

@@ -11,36 +11,51 @@ COPY Cargo.toml ./
RUN apt-get update && apt-get install -y cmake
RUN cargo build --release
# # ==========
# # Packages
# # ==========
# FROM debian:bullseye-slim as packages
# # FROM debian:bookworm-slim as packages
# WORKDIR /packages
# ==========
# Packages
# ==========
FROM debian:bookworm-slim as packages
WORKDIR /packages
# RUN apt-get update && apt-get install -y curl tar xz-utils && \
# curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux > yt-dlp && \
# # curl -L https://github.com/yt-dlp/yt-dlp/releases/download/2023.07.06/yt-dlp_linux > yt-dlp && \
# chmod +x yt-dlp && \
# curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz > ffmpeg.tar.xz && \
# # curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/autobuild-2023-06-30-14-08/ffmpeg-N-111310-g96d6990517-linux64-gpl.tar.xz > ffmpeg.tar.xz && \
# tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz
RUN apt-get update && apt-get install -y curl tar xz-utils
ARG TARGETPLATFORM
# Check if the target platform is linux/x86_64, otherwise log error and exit
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
echo "amd64" && false; \
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_armv7l > yt-dlp && \
chmod +x yt-dlp; \
elif [ "$TARGETPLATFORM" = "linux/aarch64" ]; then \
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_aarch64 > yt-dlp && \
chmod +x yt-dlp; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_aarch64 > yt-dlp && \
chmod +x yt-dlp && \
curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz > ffmpeg.tar.xz && \
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz; \
elif [ "$TARGETPLATFORM" = "linux/x86_64" ]; then \
echo "Unsupported platform: $TARGETPLATFORM" && \
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux > yt-dlp && \
chmod +x yt-dlp && \
curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz > ffmpeg.tar.xz && \
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz; \
else \
echo "Unsupported platform: $TARGETPLATFORM" && false; \
fi
# =========
# Runtime
# =========
# FROM debian:bullseye-slim as runtime
FROM debian:bookworm-slim as runtime
WORKDIR /service
USER root
COPY --from=builder /builder/target/release/service /usr/local/bin/service
# COPY --from=packages /packages /usr/bin
COPY --from=packages /packages /usr/bin
RUN apt-get update && apt-get install -y \
libc6 libc6-dev libopus-dev libpq5 libpq-dev python3-pip ffmpeg pipx
libc6 libc6-dev libopus-dev libpq5 libpq-dev python3-pip ffmpeg
# apt-get auto-remove -y && \
# pip install -U yt-dlp
RUN pipx install yt-dlp
# RUN pipx install yt-dlp
CMD ["service"]