Compare commits

...

2 Commits

Author SHA1 Message Date
Timofey Gelazoniya 7a438a24b3
update magick_rust 2023-04-29 05:59:22 +03:00
Timofey Gelazoniya 386036554e
docker distroless image 2023-04-29 05:59:03 +03:00
4 changed files with 104 additions and 22 deletions

21
Cargo.lock generated
View File

@ -99,9 +99,9 @@ dependencies = [
[[package]]
name = "bindgen"
version = "0.63.0"
version = "0.65.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36d860121800b2a9a94f9b5604b332d5cffb234ce17609ea479d723dbc9d3885"
checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5"
dependencies = [
"bitflags",
"cexpr",
@ -110,12 +110,13 @@ dependencies = [
"lazycell",
"log",
"peeking_take_while",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn 1.0.109",
"syn 2.0.13",
"which",
]
@ -445,9 +446,9 @@ dependencies = [
[[package]]
name = "magick_rust"
version = "0.17.0"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31ad8b956bdc8d2bcb4e6feaeac3642a1d91892271c9e70f2a5c408a755c26e3"
checksum = "5cf5e5282afc226caad138bcc3969f62f2460c8df3680d6036878cb5f6c0925c"
dependencies = [
"bindgen",
"libc",
@ -584,6 +585,16 @@ version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
[[package]]
name = "prettyplease"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ceca8aaf45b5c46ec7ed39fff75f57290368c1846d33d24a122ca81416ab058"
dependencies = [
"proc-macro2",
"syn 2.0.13",
]
[[package]]
name = "proc-macro2"
version = "1.0.55"

View File

@ -14,7 +14,7 @@ axum = {version = "0.6", features = ["multipart", "macros"]}
dotenvy = "0.15.7"
env_logger = "0.10.0"
log = "0.4.17"
magick_rust = "0.17.0"
magick_rust = "0.18.0"
serde = {version = "1.0.159", features = ["derive"]}
serde_json = "1.0.95"
tokio = {version = "1", features = ["macros", "rt-multi-thread"]}

View File

@ -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
View 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