Update "gif" conversion logic

This commit is contained in:
Dylan
2026-01-30 22:52:38 +00:00
parent 489bbdf026
commit d262fe1014
4 changed files with 112 additions and 124 deletions
+16 -21
View File
@@ -1,30 +1,25 @@
FROM public.ecr.aws/lambda/python:3.8 AS builder
RUN yum -y install git curl
RUN yum -y groupinstall 'Development Tools'
RUN git clone https://github.com/kohler/gifsicle
WORKDIR gifsicle
RUN autoreconf -i
RUN ./configure --disable-gifview --disable-gifdiff
RUN make
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
WORKDIR /var/task
RUN git clone https://github.com/ImageOptim/gifski
WORKDIR gifski
RUN /root/.cargo/bin/cargo build --release
FROM public.ecr.aws/lambda/python:3.12 AS builder
RUN dnf -y install git cargo && dnf clean all
RUN git clone https://github.com/ImageOptim/gifski /gifski
WORKDIR /gifski
RUN cargo build --release
FROM public.ecr.aws/lambda/python:3.8
RUN yum -y update
RUN yum -y install git && yum -y install wget && yum -y install tar.x86_64 && yum -y install xz && yum clean all
FROM public.ecr.aws/lambda/python:3.12 AS ffmpeg
RUN dnf -y update
RUN dnf -y install git wget tar.x86_64 xz && dnf clean all
WORKDIR /ffmpeg
RUN wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
RUN tar -xvf ffmpeg-release-amd64-static.tar.xz
RUN mv ff*/ffmpeg . && mv ff*/ffprobe . && rm *.tar.xz && rm -rf ff*/
COPY --from=builder /var/task/gifsicle/src/gifsicle ./
COPY --from=builder /var/task/gifski/target/release/gifski ./
FROM public.ecr.aws/lambda/python:3.12
COPY --from=builder /gifski/target/release/gifski ./
COPY --from=ffmpeg /ffmpeg/ffmpeg-*-amd64-static/ffmpeg /usr/local/bin/ffmpeg
COPY --from=ffmpeg /ffmpeg/ffmpeg-*-amd64-static/ffprobe /usr/local/bin/ffprobe
RUN pip install requests==2.32.3
# Copy function code
COPY __init__.py ${LAMBDA_TASK_ROOT}/app.py
COPY conv.sh ${LAMBDA_TASK_ROOT}/conv.sh
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.lambda_handler" ]