Added detailed comments for the Dockerfile
This commit is contained in:
parent
9fe4e2fad1
commit
369a057a7a
32
Dockerfile
32
Dockerfile
@ -1,8 +1,16 @@
|
|||||||
# Use the official golang:1.22.12-bookworm
|
# Use the official golang:1.22.12-bookworm image as the build stage
|
||||||
FROM golang:1.22.12-bookworm as build
|
FROM golang:1.22.12-bookworm as build
|
||||||
|
|
||||||
|
# Create a directory /app
|
||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
|
|
||||||
|
# Set the working directory to /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the current directory contents into /app
|
||||||
COPY ./ /app/
|
COPY ./ /app/
|
||||||
|
|
||||||
|
# Update the package list and install necessary packages
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
@ -42,28 +50,48 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
libunistring-dev \
|
libunistring-dev \
|
||||||
libaom-dev \
|
libaom-dev \
|
||||||
libdav1d-dev && \
|
libdav1d-dev && \
|
||||||
# go version && \
|
# Download Go module dependencies
|
||||||
go mod download && \
|
go mod download && \
|
||||||
|
# Download yt-dlp
|
||||||
wget --no-check-certificate -c https://github.com/yt-dlp/yt-dlp/releases/download/2025.01.26/yt-dlp_linux &&\
|
wget --no-check-certificate -c https://github.com/yt-dlp/yt-dlp/releases/download/2025.01.26/yt-dlp_linux &&\
|
||||||
|
# Download ffmpeg
|
||||||
wget --no-check-certificate -c https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-6.0.1-amd64-static.tar.xz &&\
|
wget --no-check-certificate -c https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-6.0.1-amd64-static.tar.xz &&\
|
||||||
|
# Move yt-dlp to /usr/bin and set permissions
|
||||||
mv yt-dlp_linux /usr/bin/yt-dlp && \
|
mv yt-dlp_linux /usr/bin/yt-dlp && \
|
||||||
chmod 755 /usr/bin/yt-dlp && \
|
chmod 755 /usr/bin/yt-dlp && \
|
||||||
chmod +x /usr/bin/yt-dlp && \
|
chmod +x /usr/bin/yt-dlp && \
|
||||||
|
# Extract ffmpeg tarball
|
||||||
tar -xf ffmpeg-6.0.1-amd64-static.tar.xz && \
|
tar -xf ffmpeg-6.0.1-amd64-static.tar.xz && \
|
||||||
|
# Remove the tarball
|
||||||
rm -rf ffmpeg-6.0.1-amd64-static.tar.xz && \
|
rm -rf ffmpeg-6.0.1-amd64-static.tar.xz && \
|
||||||
|
# Set execute permissions for ffmpeg and ffprobe
|
||||||
chmod +x ffmpeg-6.0.1-amd64-static/ffmpeg && \
|
chmod +x ffmpeg-6.0.1-amd64-static/ffmpeg && \
|
||||||
chmod +x ffmpeg-6.0.1-amd64-static/ffprobe && \
|
chmod +x ffmpeg-6.0.1-amd64-static/ffprobe && \
|
||||||
|
# Copy ffmpeg and ffprobe to /usr/bin
|
||||||
cp -R ffmpeg-6.0.1-amd64-static/ffmpeg /usr/bin/ && \
|
cp -R ffmpeg-6.0.1-amd64-static/ffmpeg /usr/bin/ && \
|
||||||
cp -R ffmpeg-6.0.1-amd64-static/ffprobe /usr/bin/ && \
|
cp -R ffmpeg-6.0.1-amd64-static/ffprobe /usr/bin/ && \
|
||||||
|
# Remove the extracted ffmpeg directory
|
||||||
rm -rf ffmpeg-6.0.1-amd64-static && \
|
rm -rf ffmpeg-6.0.1-amd64-static && \
|
||||||
|
# Create a new user 'papibot'
|
||||||
useradd papibot && \
|
useradd papibot && \
|
||||||
|
# Build the Go application
|
||||||
CGO_ENABLED=0 GOOS=linux go build -o /app/papibot
|
CGO_ENABLED=0 GOOS=linux go build -o /app/papibot
|
||||||
|
|
||||||
|
# Use the official golang:1.22.12-bookworm image for the final stage
|
||||||
FROM golang:1.22.12-bookworm
|
FROM golang:1.22.12-bookworm
|
||||||
|
|
||||||
|
# Create a group and user 'papibot'
|
||||||
RUN groupadd -r papibot && useradd -r -g papibot papibot
|
RUN groupadd -r papibot && useradd -r -g papibot papibot
|
||||||
|
|
||||||
|
# Switch to the 'papibot' user
|
||||||
USER papibot
|
USER papibot
|
||||||
|
|
||||||
|
# Copy the necessary files from the build stage
|
||||||
COPY --from=build --chown=papibot:papibot /usr/bin/ /usr/bin
|
COPY --from=build --chown=papibot:papibot /usr/bin/ /usr/bin
|
||||||
COPY --from=build --chown=papibot:papibot /app/ /app/
|
COPY --from=build --chown=papibot:papibot /app/ /app/
|
||||||
|
|
||||||
|
# Set the working directory to /app
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
|
|
||||||
|
# Set the entry point to the built Go application
|
||||||
ENTRYPOINT ["./papibot"]
|
ENTRYPOINT ["./papibot"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user