docker distroless image
This commit is contained in:
parent
63a4d7ac32
commit
386036554e
83
Dockerfile
83
Dockerfile
@ -1,9 +1,57 @@
|
||||
FROM fedora:38 as build
|
||||
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
|
||||
|
||||
RUN make -j $(nproc)
|
||||
RUN make install
|
||||
|
||||
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
|
||||
|
||||
RUN dnf install -y rust cargo ImageMagick-devel clang --setopt=install_weak_deps=False
|
||||
|
||||
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
|
||||
ENV PKG_CONFIG_PATH=/opt/imagemagick/lib/pkgconfig
|
||||
|
||||
WORKDIR /usr/src/liquid-rescale-api
|
||||
|
||||
@ -20,21 +68,24 @@ RUN sed -i 's|dummy.rs|src/main.rs|' Cargo.toml
|
||||
|
||||
# Copy everything
|
||||
COPY . .
|
||||
# Add the wait script
|
||||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
|
||||
RUN chmod +x /wait
|
||||
# Build our code
|
||||
RUN cargo build --release
|
||||
|
||||
FROM fedora:38
|
||||
FROM gcr.io/distroless/cc
|
||||
|
||||
RUN dnf install -y ImageMagick-devel --setopt=install_weak_deps=False \
|
||||
&& dnf clean all \
|
||||
&& rm -rf /var/cache/yum
|
||||
COPY --from=builder /usr/src/liquid-rescale-api/target/release/liquid-rescale-api /liquid-rescale-api
|
||||
|
||||
COPY --from=build /usr/src/liquid-rescale-api/target/release/liquid-rescale-api /liquid-rescale-api/liquid-rescale-api
|
||||
COPY --from=build /wait /wait
|
||||
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/libglib-2.0* /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
|
||||
|
||||
WORKDIR /liquid-rescale-api
|
||||
|
||||
CMD /wait && /liquid-rescale-api/liquid-rescale-api
|
||||
ENTRYPOINT ["./liquid-rescale-api"]
|
20
Makefile
Normal file
20
Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
build:
|
||||
docker buildx build --platform linux/amd64 -t liquid-rescale-api:latest .
|
||||
|
||||
build-plain:
|
||||
docker buildx build --platform linux/amd64 --progress plain -t liquid-rescale-api:latest .
|
||||
|
||||
build-no-cache:
|
||||
docker buildx build --platform linux/amd64 --no-cache -t liquid-rescale-api:latest .
|
||||
|
||||
shell:
|
||||
docker run --rm -it --entrypoint bash liquid-rescale-api:latest
|
||||
|
||||
run:
|
||||
docker run --name liquid-rescale-api --init --rm -it -p 3021:3000 liquid-rescale-api:latest
|
||||
|
||||
tag:
|
||||
docker tag liquid-rescale-api:latest git.zeldon.ru/zeldon/liquid-rescale-api
|
||||
|
||||
push:
|
||||
docker push git.zeldon.ru/zeldon/liquid-rescale-api:latest
|
Loading…
Reference in New Issue
Block a user