liquid-rescale-api/Dockerfile

90 lines
2.9 KiB
Docker
Raw Normal View History

2023-04-29 02:59:03 +00:00
FROM debian:11-slim as imagick-builder
ENV MAGICK_VERSION 7.1.1-8
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
2023-04-08 14:38:51 +00:00
2023-04-29 02:59:03 +00:00
RUN make -j $(nproc)
RUN make install
2023-04-08 14:38:51 +00:00
2023-04-29 02:59:03 +00:00
FROM rust:1.69.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
2023-04-08 14:38:51 +00:00
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
2023-04-29 02:59:03 +00:00
ENV PKG_CONFIG_PATH=/opt/imagemagick/lib/pkgconfig
2023-04-08 14:38:51 +00:00
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
2023-04-29 02:59:03 +00:00
FROM gcr.io/distroless/cc
2023-04-08 14:38:51 +00:00
2023-04-29 02:59:03 +00:00
COPY --from=builder /usr/src/liquid-rescale-api/target/release/liquid-rescale-api /liquid-rescale-api
2023-04-08 14:38:51 +00:00
2023-04-29 02:59:03 +00:00
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
2023-04-08 14:38:51 +00:00
2023-04-29 02:59:03 +00:00
ENTRYPOINT ["./liquid-rescale-api"]