From e199bbbca4356af0ef512bacbf0887930f3481fd Mon Sep 17 00:00:00 2001 From: watn3y Date: Fri, 27 Oct 2023 04:36:48 +0000 Subject: [PATCH] yeah i forgot to push the important files --- Dockerfile | 57 ++++++++++++++++++++++++++++++++++++++++++------------ build.sh | 4 +--- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index d01a714..0acadaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,62 @@ -# syntax=docker/dockerfile:1 -FROM golang:1.20-alpine +## syntax=docker/dockerfile:1 +#build container +FROM golang:1.21-alpine3.18 as build WORKDIR /tmp/build -#install update system and install packages +ARG TARGETPLATFORM TARGETOS TARGETARCH BUILDOS BUILDARCH + RUN apk update RUN apk upgrade --available -RUN apk add alpine-sdk ffmpeg python3 py3-pip - -#install yt-dlp -RUN pip3 install yt-dlp +RUN apk add alpine-sdk tar xz #build bloaterbot COPY . . RUN go mod download -RUN mkdir /app +RUN mkdir /tmp/build/output ARG CGO_ENABLED=1 + ENV COMMIT=${COMMIT} -RUN go build -o /app/bloaterbot +RUN go build -o /tmp/build/output/bloaterbot + +#download ffmpeg and yt-dlp + +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + wget "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz" -O "/tmp/ffmpeg.tar.xz" && wget "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux" -O "/tmp/yt-dlp" && go build -o /tmp/build/output/bloaterbot; \ + elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + wget "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz" -O "/tmp/ffmpeg.tar.xz" && wget "https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_aarch64" -O "/tmp/yt-dlp" && go build -o /tmp/build/output/bloaterbot; \ + else \ + echo "ERROR! Invalid build target" && exit 1; \ + fi + + + + +RUN mkdir /tmp/ffmpeg +RUN tar -xvf /tmp/ffmpeg.tar.xz -C /tmp/ffmpeg --strip-components=1 + + +#final container +FROM alpine:3.18 + +#update system and install packages +RUN apk update +RUN apk upgrade --available WORKDIR /app -RUN rm -rf /tmp/build -COPY bloater.webp /app +COPY --from=build /tmp/build/output/bloaterbot /app/bloaterbot -CMD [ "/app/bloaterbot" ] \ No newline at end of file +COPY --from=build /tmp/ffmpeg/ffmpeg /usr/local/bin/ffmpeg +COPY --from=build /tmp/yt-dlp /usr/local/bin/yt-dlp +RUN chmod +x /usr/local/bin/yt-dlp /usr/local/bin/ffmpeg + + +COPY bloater.webp /app/bloater.webp +COPY entrypoint.sh /app/entrypoint.sh + +RUN chmod -x /app/entrypoint.sh + +CMD ["/bin/ash", "/app/entrypoint.sh"] diff --git a/build.sh b/build.sh index 8590dbc..50d009d 100644 --- a/build.sh +++ b/build.sh @@ -1,10 +1,8 @@ ###!/usr/bin/env bash -docker login read -p 'Tag: ' tag -docker buildx create --name bloaterbuilder --use --bootstrap -docker buildx build --push --platform linux/amd64,linux/arm64 --tag watn3y/bloaterbot:$(git log -1 --pretty=%h) --tag watn3y/bloaterbot:$tag --build-arg=COMMIT=$(git log -1 --pretty=%h) . +docker build --tag watn3y/bloaterbot:$(git log -1 --pretty=%h) --tag watn3y/bloaterbot:$tag --build-arg=COMMIT=$(git log -1 --pretty=%h) .