mirror of
https://git.asonix.dog/asonix/pict-rs.git
synced 2024-11-28 12:31:00 +00:00
Get pretty comfy with dockerfiles
This commit is contained in:
parent
0801c1141f
commit
caa2168e7f
7 changed files with 210 additions and 141 deletions
|
@ -57,7 +57,7 @@ Run the following to develop in docker:
|
|||
```
|
||||
git clone https://git.asonix.dog/asonix/pict-rs
|
||||
cd pict-rs/docker/dev
|
||||
docker-compose up --build
|
||||
./dev.sh
|
||||
```
|
||||
|
||||
### API
|
||||
|
|
|
@ -3,17 +3,9 @@ FROM rustembedded/cross:x86_64-unknown-linux-gnu AS x86_64-builder
|
|||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
ENV TOOLCHAIN=stable
|
||||
ENV HOST=x86_64-unknown-linux
|
||||
ENV TARGET=$HOST-gnu
|
||||
ENV TOOL=x86_64-linux-gnu
|
||||
ENV ARCH=amd64
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y
|
||||
|
||||
RUN \
|
||||
apt-get upgrade -y && \
|
||||
addgroup --gid "${GID}" build && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
|
@ -31,7 +23,13 @@ RUN \
|
|||
USER build
|
||||
WORKDIR /opt/build
|
||||
|
||||
ENV PATH=$PATH:/opt/build/.cargo/bin
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin \
|
||||
TOOLCHAIN=stable \
|
||||
HOST=x86_64-unknown-linux \
|
||||
TARGET=x86_64-unknown-linux-gnu \
|
||||
TOOL=x86_64-linux-gnu \
|
||||
ARCH=amd64
|
||||
|
||||
RUN \
|
||||
chmod +x rustup.sh && \
|
||||
|
@ -53,12 +51,14 @@ RUN \
|
|||
libjpeg-dev:$ARCH \
|
||||
libpng-dev:$ARCH \
|
||||
libwebp-dev:$ARCH \
|
||||
libxml2-dev:$ARCH && \
|
||||
liblzma-dev:$ARCH \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
clang && \
|
||||
chown build:build ImageMagick.tar.gz
|
||||
|
||||
|
||||
USER build
|
||||
ENV USER=build
|
||||
|
||||
RUN \
|
||||
tar xvzf ImageMagick.tar.gz && \
|
||||
|
@ -66,6 +66,16 @@ RUN \
|
|||
|
||||
WORKDIR /opt/build/ImageMagick
|
||||
|
||||
ENV \
|
||||
USER=build \
|
||||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=/usr/lib/$TOOL \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/usr/lib/$TOOL \
|
||||
LDFLAGS="$LDFLAGS -L/usr/lib/$TOOL -Wl,-rpath-link,/usr/lib/$TOOL" \
|
||||
CFLAGS="$CFLAGS -I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include" \
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include"
|
||||
|
||||
RUN \
|
||||
./configure \
|
||||
CC=$TOOL-gcc \
|
||||
|
@ -88,20 +98,11 @@ RUN \
|
|||
make install && \
|
||||
ldconfig /imagemagick/lib
|
||||
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/imagemagick/lib
|
||||
ENV LD_RUN_PATH=$LD_RUN_PATH:/imagemagick/lib
|
||||
ENV LDFLAGS="$LDFLAGS -L/imagemagick/lib"
|
||||
ENV RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL"
|
||||
ENV IMAGE_MAGICK_LIB_DIRS=/imagemagick/lib
|
||||
ENV IMAGE_MAGICK_INCLUDE_DIRS=/imagemagick/include/ImageMagick-7
|
||||
ENV PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/$TOOL/pkgconfig:/usr/lib/$PKGCONFIG:/imagemagick/lib/pkgconfig
|
||||
ENV CPPFLAGS="$CPPFLAGS -I/imagemagick/include/ImageMagick-7 -I/usr/lib/llvm-6.0/lib/clang/6.0.0/include"
|
||||
|
||||
USER build
|
||||
|
||||
WORKDIR /opt/build
|
||||
|
||||
# Cache deps
|
||||
RUN \
|
||||
cargo new repo
|
||||
|
||||
|
@ -111,17 +112,20 @@ COPY Cargo.toml Cargo.lock ./
|
|||
|
||||
USER root
|
||||
RUN \
|
||||
chown -R build:build ./ && \
|
||||
apt-get install -y \
|
||||
llvm-dev:$ARCH \
|
||||
libclang-dev:$ARCH \
|
||||
clang:$ARCH
|
||||
chown -R build:build ./
|
||||
|
||||
USER build
|
||||
|
||||
RUN \
|
||||
ls /imagemagick/* && \
|
||||
ls /imagemagick/*/*
|
||||
ENV \
|
||||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/imagemagick/lib \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/imagemagick/lib \
|
||||
LDFLAGS="$LDFLAGS -L/imagemagick/lib" \
|
||||
RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL" \
|
||||
IMAGE_MAGICK_LIB_DIRS=/imagemagick/lib \
|
||||
IMAGE_MAGICK_INCLUDE_DIRS=/imagemagick/include/ImageMagick-7 \
|
||||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/imagemagick/lib/pkgconfig \
|
||||
CFLAGS="$CFLAGS -I/imagemagick/include/ImageMagick-7" \
|
||||
CPPFLAGS="$CPPFLAGS -I/imagemagick/include/ImageMagick-7"
|
||||
|
||||
RUN \
|
||||
mkdir -p ./src && \
|
||||
|
@ -138,35 +142,38 @@ RUN \
|
|||
|
||||
USER build
|
||||
|
||||
# Build
|
||||
RUN cargo build --frozen
|
||||
|
||||
FROM ubuntu:20.04
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
libgexiv2-2 \
|
||||
libgomp1 \
|
||||
libltdl7
|
||||
|
||||
|
||||
# Copy resources
|
||||
COPY --from=builder /opt/build/repo/target/debug/pict-rs /usr/bin/pict-rs
|
||||
COPY --from=builder /imagemagick /imagemagick
|
||||
ARG BINARY=pict-rs
|
||||
ARG TARGET=x86_64-unknown-linux-gnu
|
||||
|
||||
RUN \
|
||||
addgroup -gid "${GID}" pictrs && \
|
||||
apt-get update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install \
|
||||
tini \
|
||||
libgexiv2-2 \
|
||||
libgomp1 \
|
||||
libltdl7 && \
|
||||
addgroup --gid $GID pictrs && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--ingroup pictrs \
|
||||
--uid "${UID}" \
|
||||
--uid $UID \
|
||||
--home /opt/pictrs \
|
||||
pictrs
|
||||
|
||||
COPY --from=builder /imagemagick /imagemagick
|
||||
COPY --from=builder /opt/build/repo/target/debug/$BINARY /usr/bin/$BINARY
|
||||
|
||||
VOLUME /mnt
|
||||
WORKDIR /opt/pictrs
|
||||
USER pictrs
|
||||
EXPOSE 8080
|
||||
CMD ["/usr/bin/pict-rs"]
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["/usr/bin/pict-rs", "-p", "/mnt", "-a", "0.0.0.0:8080"]
|
||||
|
|
8
docker/dev/dev.sh
Executable file
8
docker/dev/dev.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export USER_ID=$(id -u)
|
||||
export GROUP_ID=$(id -g)
|
||||
|
||||
mkdir -p ./volumes/pictrs
|
||||
|
||||
docker-compose up --build
|
|
@ -5,11 +5,13 @@ services:
|
|||
build:
|
||||
context: ../../
|
||||
dockerfile: docker/dev/Dockerfile
|
||||
user: root
|
||||
args:
|
||||
UID: "${USER_ID:-1000}"
|
||||
GID: "${GROUP_ID:-1000}"
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
restart: always
|
||||
environment:
|
||||
- PICTRS_PATH=/app/data
|
||||
volumes:
|
||||
- ./volumes/pictrs:/app/data
|
||||
- ./volumes/pictrs:/mnt
|
||||
|
|
|
@ -3,17 +3,9 @@ FROM rustembedded/cross:x86_64-unknown-linux-gnu AS x86_64-builder
|
|||
ARG UID=991
|
||||
ARG GID=991
|
||||
|
||||
ENV TOOLCHAIN=stable
|
||||
ENV HOST=x86_64-unknown-linux
|
||||
ENV TARGET=$HOST-gnu
|
||||
ENV TOOL=x86_64-linux-gnu
|
||||
ENV ARCH=amd64
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y
|
||||
|
||||
RUN \
|
||||
apt-get upgrade -y && \
|
||||
addgroup --gid "${GID}" build && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
|
@ -31,13 +23,20 @@ RUN \
|
|||
USER build
|
||||
WORKDIR /opt/build
|
||||
|
||||
ENV PATH=$PATH:/opt/build/.cargo/bin
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin \
|
||||
TOOLCHAIN=stable \
|
||||
HOST=x86_64-unknown-linux \
|
||||
TARGET=x86_64-unknown-linux-gnu \
|
||||
TOOL=x86_64-linux-gnu \
|
||||
ARCH=amd64
|
||||
|
||||
RUN \
|
||||
chmod +x rustup.sh && \
|
||||
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
|
||||
rustup target add $TARGET
|
||||
|
||||
|
||||
FROM x86_64-builder as builder
|
||||
|
||||
USER root
|
||||
|
@ -54,19 +53,14 @@ RUN \
|
|||
libpng-dev:$ARCH \
|
||||
libwebp-dev:$ARCH \
|
||||
libxml2-dev:$ARCH \
|
||||
liblzma-dev:$ARCH && \
|
||||
liblzma-dev:$ARCH \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
clang && \
|
||||
chown build:build ImageMagick.tar.gz
|
||||
|
||||
|
||||
USER build
|
||||
ENV USER=build
|
||||
|
||||
ENV PKG_CONFIG_ALLOW_CROSS=1
|
||||
ENV PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/$PKGCONFIG
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/$TOOL
|
||||
ENV LD_RUN_PATH=$LD_RUN_PATH:/usr/lib/$TOOL:/usr/lib
|
||||
ENV LDFLAGS="$LDFLAGS -L/usr/lib/$TOOL -Wl,-rpath-link,/usr/lib/$TOOL"
|
||||
ENV CPPFLAGS="$CPPFLAGS -I/usr/include -I/usr/include/$TOOL"
|
||||
|
||||
RUN \
|
||||
tar xzf ImageMagick.tar.gz && \
|
||||
|
@ -74,6 +68,16 @@ RUN \
|
|||
|
||||
WORKDIR /opt/build/ImageMagick
|
||||
|
||||
ENV \
|
||||
USER=build \
|
||||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=/usr/lib/$TOOL \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/usr/lib/$TOOL \
|
||||
LDFLAGS="$LDFLAGS -L/usr/lib/$TOOL -Wl,-rpath-link,/usr/lib/$TOOL" \
|
||||
CFLAGS="$CFLAGS -I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include" \
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include"
|
||||
|
||||
RUN \
|
||||
./configure \
|
||||
CC=$TOOL-gcc \
|
||||
|
@ -97,14 +101,10 @@ RUN \
|
|||
make install && \
|
||||
ldconfig /imagemagick/lib
|
||||
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/imagemagick/lib
|
||||
ENV LD_RUN_PATH=$LD_RUN_PATH:/imagemagick/lib
|
||||
ENV LDFLAGS="$LDFLAGS -L/imagemagick/lib"
|
||||
ENV RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL"
|
||||
ENV IMAGE_MAGICK_DIR=/imagemagick
|
||||
|
||||
USER build
|
||||
|
||||
WORKDIR /opt/build
|
||||
|
||||
ARG TAG=master
|
||||
ARG REPOSITORY=https://git.asonix.dog/asonix/pict-rs
|
||||
ARG BINARY=pict-rs
|
||||
|
@ -114,22 +114,36 @@ RUN \
|
|||
|
||||
WORKDIR /opt/build/repo
|
||||
|
||||
ENV \
|
||||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/imagemagick/lib \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/imagemagick/lib \
|
||||
LDFLAGS="$LDFLAGS -L/imagemagick/lib" \
|
||||
RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL" \
|
||||
IMAGE_MAGICK_LIB_DIRS=/imagemagick/lib \
|
||||
IMAGE_MAGICK_INCLUDE_DIRS=/imagemagick/include/ImageMagick-7 \
|
||||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/imagemagick/lib/pkgconfig \
|
||||
CFLAGS="$CFLAGS -I/imagemagick/include/ImageMagick-7" \
|
||||
CPPFLAGS="$CPPFLAGS -I/imagemagick/include/ImageMagick-7"
|
||||
|
||||
RUN \
|
||||
cargo build --release --target $TARGET && \
|
||||
$TOOL-strip target/$TARGET/release/$BINARY
|
||||
|
||||
FROM amd64/ubuntu:20.04
|
||||
|
||||
ARG TARGET=x86_64-unknown-linux-gnu
|
||||
ARG UID=991
|
||||
ARG GID=991
|
||||
ARG BINARY=pict-rs
|
||||
|
||||
COPY --from=builder /opt/build/repo/target/x86_64-unknown-linux-gnu/release/$BINARY /usr/bin/$BINARY
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install tini libgexiv2-2 && \
|
||||
apt-get -y install \
|
||||
tini \
|
||||
libgexiv2-2 \
|
||||
libgomp1 \
|
||||
libltdl7 && \
|
||||
addgroup --gid $GID pictrs && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
|
@ -137,13 +151,15 @@ RUN \
|
|||
--ingroup pictrs \
|
||||
--uid $UID \
|
||||
--home /opt/pictrs \
|
||||
pictrs
|
||||
|
||||
RUN \
|
||||
pictrs && \
|
||||
chown -R pictrs:pictrs /mnt
|
||||
|
||||
COPY --from=builder /imagemagick /imagemagick
|
||||
COPY --from=builder /opt/build/repo/target/$TARGET/release/$BINARY /usr/bin/$BINARY
|
||||
|
||||
VOLUME /mnt
|
||||
WORKDIR /opt/pictrs
|
||||
USER pictrs
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["/usr/bin/pict-rs", "-p", "/mnt", "-a", "0.0.0.0:8080", "-w", "thumbnail"]
|
||||
|
|
|
@ -3,17 +3,9 @@ FROM rustembedded/cross:arm-unknown-linux-gnueabihf AS arm32v7-builder
|
|||
ARG UID=991
|
||||
ARG GID=991
|
||||
|
||||
ENV TOOLCHAIN=stable
|
||||
ENV HOST=arm-unknown-linux
|
||||
ENV TARGET=$HOST-gnueabihf
|
||||
ENV TOOL=arm-linux-gnueabihf
|
||||
ENV ARCH=armhf
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y
|
||||
|
||||
RUN \
|
||||
apt-get upgrade -y && \
|
||||
addgroup --gid "${GID}" build && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
|
@ -31,13 +23,20 @@ RUN \
|
|||
USER build
|
||||
WORKDIR /opt/build
|
||||
|
||||
ENV PATH=$PATH:/opt/build/.cargo/bin
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin \
|
||||
TOOLCHAIN=stable \
|
||||
HOST=arm-unknown-linux \
|
||||
TARGET=arm-unknown-linux-gnueabihf \
|
||||
TOOL=arm-linux-gnueabihf \
|
||||
ARCH=armhf
|
||||
|
||||
RUN \
|
||||
chmod +x rustup.sh && \
|
||||
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
|
||||
rustup target add $TARGET
|
||||
|
||||
|
||||
FROM arm32v7-builder as builder
|
||||
|
||||
USER root
|
||||
|
@ -55,6 +54,10 @@ RUN \
|
|||
libwebp-dev:$ARCH \
|
||||
libxml2-dev:$ARCH \
|
||||
liblzma-dev:$ARCH \
|
||||
libc6-dev-$ARCH-cross \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
clang \
|
||||
libexpat1-dev:$ARCH && \
|
||||
ln -s /usr/lib/$TOOL/libpcre.so /usr/lib/$TOOL/libpcre.so.3 && \
|
||||
ln -s /usr/lib/$TOOL/libz.so /usr/lib/$TOOL/libz.so.1 && \
|
||||
|
@ -63,14 +66,6 @@ RUN \
|
|||
|
||||
|
||||
USER build
|
||||
ENV USER=build
|
||||
|
||||
ENV PKG_CONFIG_ALLOW_CROSS=1
|
||||
ENV PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/$PKGCONFIG
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/$TOOL
|
||||
ENV LD_RUN_PATH=$LD_RUN_PATH:/usr/lib/$TOOL:/usr/lib
|
||||
ENV LDFLAGS="$LDFLAGS -L/usr/lib/$TOOL -Wl,-rpath-link,/usr/lib/$TOOL"
|
||||
ENV CPPFLAGS="$CPPFLAGS -I/usr/include -I/usr/include/$TOOL"
|
||||
|
||||
RUN \
|
||||
tar xzf ImageMagick.tar.gz && \
|
||||
|
@ -78,6 +73,16 @@ RUN \
|
|||
|
||||
WORKDIR /opt/build/ImageMagick
|
||||
|
||||
ENV \
|
||||
USER=build \
|
||||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=/usr/lib/$TOOL \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/usr/lib/$TOOL \
|
||||
LDFLAGS="$LDFLAGS -L/usr/lib/$TOOL -Wl,-rpath-link,/usr/lib/$TOOL" \
|
||||
CFLAGS="$CFLAGS -I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include" \
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include"
|
||||
|
||||
RUN \
|
||||
./configure \
|
||||
CC=$TOOL-gcc \
|
||||
|
@ -99,16 +104,13 @@ USER root
|
|||
|
||||
RUN \
|
||||
make install && \
|
||||
ldconfig /imagemagick/lib
|
||||
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/imagemagick/lib
|
||||
ENV LD_RUN_PATH=$LD_RUN_PATH:/imagemagick/lib
|
||||
ENV LDFLAGS="$LDFLAGS -L/imagemagick/lib"
|
||||
ENV RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL"
|
||||
ENV IMAGE_MAGICK_DIR=/imagemagick
|
||||
ldconfig /imagemagick/lib && \
|
||||
rm -r /usr/include/x86_64-linux-gnu
|
||||
|
||||
USER build
|
||||
|
||||
WORKDIR /opt/build
|
||||
|
||||
ARG TAG=master
|
||||
ARG REPOSITORY=https://git.asonix.dog/asonix/pict-rs
|
||||
ARG BINARY=pict-rs
|
||||
|
@ -118,22 +120,36 @@ RUN \
|
|||
|
||||
WORKDIR /opt/build/repo
|
||||
|
||||
ENV \
|
||||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/imagemagick/lib \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/imagemagick/lib \
|
||||
LDFLAGS="$LDFLAGS -L/imagemagick/lib" \
|
||||
RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL" \
|
||||
IMAGE_MAGICK_LIB_DIRS=/imagemagick/lib \
|
||||
IMAGE_MAGICK_INCLUDE_DIRS=/imagemagick/include/ImageMagick-7 \
|
||||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/imagemagick/lib/pkgconfig \
|
||||
CFLAGS="$CFLAGS -I/imagemagick/include/ImageMagick-7" \
|
||||
CPPFLAGS="$CPPFLAGS -I/imagemagick/include/ImageMagick-7"
|
||||
|
||||
RUN \
|
||||
cargo build --release --target $TARGET && \
|
||||
$TOOL-strip target/$TARGET/release/$BINARY
|
||||
|
||||
FROM arm32v7/ubuntu:20.04
|
||||
|
||||
ARG TARGET=arm-unknown-linux-gnueabihf
|
||||
ARG UID=991
|
||||
ARG GID=991
|
||||
ARG BINARY=pict-rs
|
||||
|
||||
COPY --from=builder /opt/build/repo/target/arm-unknown-linux-gnueabihf/release/$BINARY /usr/bin/$BINARY
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install tini libgexiv2-2 && \
|
||||
apt-get -y install \
|
||||
tini \
|
||||
libgexiv2-2 \
|
||||
libgomp1 \
|
||||
libltdl7 && \
|
||||
addgroup --gid $GID pictrs && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
|
@ -141,13 +157,15 @@ RUN \
|
|||
--ingroup pictrs \
|
||||
--uid $UID \
|
||||
--home /opt/pictrs \
|
||||
pictrs
|
||||
|
||||
RUN \
|
||||
pictrs && \
|
||||
chown -R pictrs:pictrs /mnt
|
||||
|
||||
COPY --from=builder /imagemagick /imagemagick
|
||||
COPY --from=builder /opt/build/repo/target/$TARGET/release/$BINARY /usr/bin/$BINARY
|
||||
|
||||
VOLUME /mnt
|
||||
WORKDIR /opt/pictrs
|
||||
USER pictrs
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["/usr/bin/pict-rs", "-p", "/mnt", "-a", "0.0.0.0:8080", "-w", "thumbnail"]
|
||||
|
|
|
@ -3,17 +3,9 @@ FROM rustembedded/cross:aarch64-unknown-linux-gnu AS aarch64-builder
|
|||
ARG UID=991
|
||||
ARG GID=991
|
||||
|
||||
ENV TOOLCHAIN=stable
|
||||
ENV HOST=aarch64-unknown-linux
|
||||
ENV TARGET=$HOST-gnu
|
||||
ENV TOOL=aarch64-linux-gnu
|
||||
ENV ARCH=arm64
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y
|
||||
|
||||
RUN \
|
||||
apt-get upgrade -y && \
|
||||
addgroup --gid "${GID}" build && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
|
@ -31,13 +23,20 @@ RUN \
|
|||
USER build
|
||||
WORKDIR /opt/build
|
||||
|
||||
ENV PATH=$PATH:/opt/build/.cargo/bin
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin \
|
||||
TOOLCHAIN=stable \
|
||||
HOST=aarch64-unknown-linux \
|
||||
TARGET=aarch64-unknown-linux-gnu \
|
||||
TOOL=aarch64-linux-gnu \
|
||||
ARCH=arm64
|
||||
|
||||
RUN \
|
||||
chmod +x rustup.sh && \
|
||||
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
|
||||
rustup target add $TARGET
|
||||
|
||||
|
||||
FROM aarch64-builder as builder
|
||||
|
||||
USER root
|
||||
|
@ -54,19 +53,15 @@ RUN \
|
|||
libpng-dev:$ARCH \
|
||||
libwebp-dev:$ARCH \
|
||||
libxml2-dev:$ARCH \
|
||||
liblzma-dev:$ARCH && \
|
||||
liblzma-dev:$ARCH \
|
||||
libc6-dev-$ARCH-cross \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
clang && \
|
||||
chown build:build ImageMagick.tar.gz
|
||||
|
||||
|
||||
USER build
|
||||
ENV USER=build
|
||||
|
||||
ENV PKG_CONFIG_ALLOW_CROSS=1
|
||||
ENV PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/$PKGCONFIG
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/$TOOL
|
||||
ENV LD_RUN_PATH=$LD_RUN_PATH:/usr/lib/$TOOL:/usr/lib
|
||||
ENV LDFLAGS="$LDFLAGS -L/usr/lib/$TOOL -Wl,-rpath-link,/usr/lib/$TOOL"
|
||||
ENV CPPFLAGS="$CPPFLAGS -I/usr/include -I/usr/include/$TOOL"
|
||||
|
||||
RUN \
|
||||
tar xzf ImageMagick.tar.gz && \
|
||||
|
@ -74,6 +69,16 @@ RUN \
|
|||
|
||||
WORKDIR /opt/build/ImageMagick
|
||||
|
||||
ENV \
|
||||
USER=build \
|
||||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=/usr/lib/$TOOL \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/usr/lib/$TOOL \
|
||||
LDFLAGS="$LDFLAGS -L/usr/lib/$TOOL -Wl,-rpath-link,/usr/lib/$TOOL" \
|
||||
CFLAGS="$CFLAGS -I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include" \
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include"
|
||||
|
||||
RUN \
|
||||
./configure \
|
||||
CC=$TOOL-gcc \
|
||||
|
@ -95,16 +100,13 @@ USER root
|
|||
|
||||
RUN \
|
||||
make install && \
|
||||
ldconfig /imagemagick/lib
|
||||
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/imagemagick/lib
|
||||
ENV LD_RUN_PATH=$LD_RUN_PATH:/imagemagick/lib
|
||||
ENV LDFLAGS="$LDFLAGS -L/imagemagick/lib"
|
||||
ENV RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL"
|
||||
ENV IMAGE_MAGICK_DIR=/imagemagick
|
||||
ldconfig /imagemagick/lib && \
|
||||
rm -r /usr/include/x86_64-linux-gnu
|
||||
|
||||
USER build
|
||||
|
||||
WORKDIR /opt/build
|
||||
|
||||
ARG TAG=master
|
||||
ARG REPOSITORY=https://git.asonix.dog/asonix/pict-rs
|
||||
ARG BINARY=pict-rs
|
||||
|
@ -114,22 +116,36 @@ RUN \
|
|||
|
||||
WORKDIR /opt/build/repo
|
||||
|
||||
ENV \
|
||||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/imagemagick/lib \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/imagemagick/lib \
|
||||
LDFLAGS="$LDFLAGS -L/imagemagick/lib" \
|
||||
RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL" \
|
||||
IMAGE_MAGICK_LIB_DIRS=/imagemagick/lib \
|
||||
IMAGE_MAGICK_INCLUDE_DIRS=/imagemagick/include/ImageMagick-7 \
|
||||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/imagemagick/lib/pkgconfig \
|
||||
CFLAGS="$CFLAGS -I/imagemagick/include/ImageMagick-7" \
|
||||
CPPFLAGS="$CPPFLAGS -I/imagemagick/include/ImageMagick-7"
|
||||
|
||||
RUN \
|
||||
cargo build --release --target $TARGET && \
|
||||
$TOOL-strip target/$TARGET/release/$BINARY
|
||||
|
||||
FROM arm64v8/ubuntu:20.04
|
||||
|
||||
ARG TARGET=aarch64-unknown-linux-gnu
|
||||
ARG UID=991
|
||||
ARG GID=991
|
||||
ARG BINARY=pict-rs
|
||||
|
||||
COPY --from=builder /opt/build/repo/target/aarch64-unknown-linux-gnu/release/$BINARY /usr/bin/$BINARY
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install tini libgexiv2-2 && \
|
||||
apt-get -y install \
|
||||
tini \
|
||||
libgexiv2-2 \
|
||||
libgomp1 \
|
||||
libltdl7 && \
|
||||
addgroup --gid $GID pictrs && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
|
@ -137,13 +153,15 @@ RUN \
|
|||
--ingroup pictrs \
|
||||
--uid $UID \
|
||||
--home /opt/pictrs \
|
||||
pictrs
|
||||
|
||||
RUN \
|
||||
pictrs && \
|
||||
chown -R pictrs:pictrs /mnt
|
||||
|
||||
COPY --from=builder /imagemagick /imagemagick
|
||||
COPY --from=builder /opt/build/repo/target/$TARGET/release/$BINARY /usr/bin/$BINARY
|
||||
|
||||
VOLUME /mnt
|
||||
WORKDIR /opt/pictrs
|
||||
USER pictrs
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["/usr/bin/pict-rs", "-p", "/mnt", "-a", "0.0.0.0:8080", "-w", "thumbnail"]
|
||||
|
|
Loading…
Reference in a new issue