liquid-rescale-api-v2/Dockerfile

90 lines
2.9 KiB
Docker
Raw Permalink Normal View History

2023-07-13 14:00:09 +00:00
FROM debian:11-slim as imagick-builder
ENV MAGICK_VERSION 7.1.1-12
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
wget \
ca-certificates \
build-essential \
clang \
glib-2.0 \
pkg-config \
libjpeg-dev \
libpng-dev \
liblqr-1-0-dev \
&& apt-get clean
WORKDIR /source
RUN wget "https://github.com/ImageMagick/ImageMagick/archive/${MAGICK_VERSION}.tar.gz"
WORKDIR /build
RUN tar -xvf "/source/${MAGICK_VERSION}.tar.gz" --strip-components=1
RUN ./configure \
--prefix=/opt/imagemagick \
--disable-docs \
--disable-openmp \
--with-gcc-arch=generic \
--with-gslib=no \
--with-magick-plus-plus=no \
--with-perl=no \
| tee configure.log
RUN make -j $(nproc)
RUN make install
FROM rust:1.70.0-slim as builder
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
ca-certificates \
clang \
pkg-config \
&& apt-get clean
COPY --from=imagick-builder /opt/imagemagick /opt/imagemagick
COPY --from=imagick-builder /usr/lib/x86_64-linux-gnu/libjpeg* /usr/lib/x86_64-linux-gnu
COPY --from=imagick-builder /usr/lib/x86_64-linux-gnu/libpng16* /usr/lib/x86_64-linux-gnu
COPY --from=imagick-builder /usr/lib/x86_64-linux-gnu/liblqr-1* /usr/lib/x86_64-linux-gnu
COPY --from=imagick-builder /usr/lib/x86_64-linux-gnu/libglib-2.0* /usr/lib/x86_64-linux-gnu
ENV PKG_CONFIG_ALLOW_CROSS=1
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
ENV PKG_CONFIG_PATH=/opt/imagemagick/lib/pkgconfig
WORKDIR /usr/src/liquid-rescale-api
# Download and compile deps
COPY Cargo.toml .
COPY Cargo.lock .
COPY docker_utils/dummy.rs .
# Change temporarely the path of the code
RUN sed -i 's|src/main.rs|dummy.rs|' Cargo.toml
# Build only deps
RUN cargo build --release
# Now return the file back to normal
RUN sed -i 's|dummy.rs|src/main.rs|' Cargo.toml
# Copy everything
COPY . .
# Build our code
RUN cargo build --release
FROM gcr.io/distroless/cc
COPY --from=builder /usr/src/liquid-rescale-api/target/release/liquid-rescale-api /liquid-rescale-api
COPY --from=imagick-builder /opt/imagemagick /
COPY --from=imagick-builder /usr/lib/x86_64-linux-gnu/libjpeg* /usr/lib/x86_64-linux-gnu
COPY --from=imagick-builder /usr/lib/x86_64-linux-gnu/libpng16* /usr/lib/x86_64-linux-gnu
COPY --from=imagick-builder /usr/lib/x86_64-linux-gnu/liblqr-1* /usr/lib/x86_64-linux-gnu
COPY --from=imagick-builder /usr/lib/x86_64-linux-gnu/libglib-2.0* /usr/lib/x86_64-linux-gnu
COPY --from=imagick-builder /lib/x86_64-linux-gnu/libz* /lib/x86_64-linux-gnu
COPY --from=imagick-builder /lib/x86_64-linux-gnu/libpthread* /lib/x86_64-linux-gnu
COPY --from=imagick-builder /lib/x86_64-linux-gnu/libm* /lib/x86_64-linux-gnu
COPY --from=imagick-builder /lib/x86_64-linux-gnu/libc* /lib/x86_64-linux-gnu
COPY --from=imagick-builder /lib/x86_64-linux-gnu/libpcre* /lib/x86_64-linux-gnu
COPY --from=imagick-builder /lib64/ld-* /lib64
ENTRYPOINT ["./liquid-rescale-api"]