2020-06-15 02:41:45 +00:00
|
|
|
FROM rustembedded/cross:x86_64-unknown-linux-gnu AS x86_64-builder
|
|
|
|
|
|
|
|
ARG UID=1000
|
|
|
|
ARG GID=1000
|
|
|
|
|
|
|
|
RUN \
|
|
|
|
apt-get update && \
|
2020-06-16 00:35:39 +00:00
|
|
|
apt-get upgrade -y && \
|
2020-06-15 02:41:45 +00:00
|
|
|
addgroup --gid "${GID}" build && \
|
|
|
|
adduser \
|
|
|
|
--disabled-password \
|
|
|
|
--gecos "" \
|
|
|
|
--ingroup build \
|
|
|
|
--uid "${UID}" \
|
|
|
|
--home /opt/build \
|
|
|
|
build
|
|
|
|
|
|
|
|
ADD https://sh.rustup.rs /opt/build/rustup.sh
|
|
|
|
|
|
|
|
RUN \
|
|
|
|
chown -R build:build /opt/build
|
|
|
|
|
|
|
|
USER build
|
|
|
|
WORKDIR /opt/build
|
|
|
|
|
2020-06-16 00:35:39 +00:00
|
|
|
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
|
2020-06-15 02:41:45 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-06-15 19:20:25 +00:00
|
|
|
ADD https://imagemagick.org/download/ImageMagick.tar.gz ./
|
|
|
|
|
2020-06-15 02:41:45 +00:00
|
|
|
RUN \
|
2020-06-15 19:20:25 +00:00
|
|
|
dpkg --add-architecture $ARCH && \
|
2020-06-15 02:41:45 +00:00
|
|
|
apt-get update && \
|
2020-06-15 19:20:25 +00:00
|
|
|
apt-get -y install \
|
|
|
|
libgexiv2-dev:$ARCH \
|
|
|
|
libltdl-dev:$ARCH \
|
|
|
|
libjpeg-dev:$ARCH \
|
|
|
|
libpng-dev:$ARCH \
|
|
|
|
libwebp-dev:$ARCH \
|
2020-06-16 00:35:39 +00:00
|
|
|
liblzma-dev:$ARCH \
|
|
|
|
llvm-dev \
|
|
|
|
libclang-dev \
|
|
|
|
clang && \
|
2020-06-15 19:20:25 +00:00
|
|
|
chown build:build ImageMagick.tar.gz
|
|
|
|
|
2020-06-15 02:41:45 +00:00
|
|
|
|
|
|
|
USER build
|
2020-06-07 20:21:25 +00:00
|
|
|
|
2020-06-15 19:20:25 +00:00
|
|
|
RUN \
|
|
|
|
tar xvzf ImageMagick.tar.gz && \
|
|
|
|
mv ImageMagick-* ImageMagick
|
|
|
|
|
|
|
|
WORKDIR /opt/build/ImageMagick
|
|
|
|
|
2020-06-16 00:35:39 +00:00
|
|
|
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"
|
|
|
|
|
2020-06-15 19:20:25 +00:00
|
|
|
RUN \
|
|
|
|
./configure \
|
|
|
|
CC=$TOOL-gcc \
|
|
|
|
CXX=$TOOL-g++ \
|
|
|
|
--prefix=/imagemagick \
|
|
|
|
--with-modules \
|
|
|
|
--enable-shared \
|
|
|
|
--disable-static \
|
|
|
|
--without-perl \
|
|
|
|
--with-xml=yes \
|
|
|
|
--with-png=yes \
|
|
|
|
--with-jpeg=yes \
|
|
|
|
--with-webp=yes \
|
|
|
|
--host=$HOST && \
|
|
|
|
make
|
|
|
|
|
|
|
|
USER root
|
|
|
|
|
|
|
|
RUN \
|
|
|
|
make install && \
|
|
|
|
ldconfig /imagemagick/lib
|
|
|
|
|
|
|
|
|
|
|
|
USER build
|
|
|
|
|
|
|
|
WORKDIR /opt/build
|
|
|
|
|
2020-06-15 02:41:45 +00:00
|
|
|
RUN \
|
|
|
|
cargo new repo
|
|
|
|
|
|
|
|
WORKDIR /opt/build/repo
|
|
|
|
|
2020-06-07 20:21:25 +00:00
|
|
|
COPY Cargo.toml Cargo.lock ./
|
2020-06-15 02:41:45 +00:00
|
|
|
|
|
|
|
USER root
|
|
|
|
RUN \
|
2020-06-16 00:35:39 +00:00
|
|
|
chown -R build:build ./
|
2020-06-15 02:41:45 +00:00
|
|
|
|
|
|
|
USER build
|
|
|
|
|
2020-06-16 00:35:39 +00:00
|
|
|
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"
|
2020-06-15 19:20:25 +00:00
|
|
|
|
2020-06-15 02:41:45 +00:00
|
|
|
RUN \
|
|
|
|
mkdir -p ./src && \
|
|
|
|
echo 'fn main() { println!("Dummy") }' > ./src/main.rs && \
|
2020-06-15 19:20:25 +00:00
|
|
|
cargo build && \
|
2020-06-15 02:41:45 +00:00
|
|
|
rm -rf ./src
|
|
|
|
|
2020-06-07 20:21:25 +00:00
|
|
|
COPY src ./src/
|
|
|
|
|
2020-06-15 02:41:45 +00:00
|
|
|
USER root
|
|
|
|
RUN \
|
|
|
|
chown -R build:build ./src && \
|
2020-06-15 19:20:25 +00:00
|
|
|
rm -r ./target/debug/deps/pict_rs-*
|
2020-06-15 02:41:45 +00:00
|
|
|
|
|
|
|
USER build
|
|
|
|
|
2020-06-15 19:20:25 +00:00
|
|
|
RUN cargo build --frozen
|
2020-06-07 20:21:25 +00:00
|
|
|
|
2020-06-15 02:41:45 +00:00
|
|
|
FROM ubuntu:20.04
|
|
|
|
|
|
|
|
ARG UID=1000
|
|
|
|
ARG GID=1000
|
2020-06-16 00:35:39 +00:00
|
|
|
ARG BINARY=pict-rs
|
|
|
|
ARG TARGET=x86_64-unknown-linux-gnu
|
2020-06-07 20:21:25 +00:00
|
|
|
|
2020-06-15 02:41:45 +00:00
|
|
|
RUN \
|
2020-06-16 00:35:39 +00:00
|
|
|
apt-get update && \
|
|
|
|
apt-get -y upgrade && \
|
|
|
|
apt-get -y install \
|
|
|
|
tini \
|
|
|
|
libgexiv2-2 \
|
|
|
|
libgomp1 \
|
|
|
|
libltdl7 && \
|
|
|
|
addgroup --gid $GID pictrs && \
|
2020-06-15 02:41:45 +00:00
|
|
|
adduser \
|
|
|
|
--disabled-password \
|
|
|
|
--gecos "" \
|
|
|
|
--ingroup pictrs \
|
2020-06-16 00:35:39 +00:00
|
|
|
--uid $UID \
|
2020-06-15 02:41:45 +00:00
|
|
|
--home /opt/pictrs \
|
|
|
|
pictrs
|
2020-06-16 00:35:39 +00:00
|
|
|
|
|
|
|
COPY --from=builder /imagemagick /imagemagick
|
|
|
|
COPY --from=builder /opt/build/repo/target/debug/$BINARY /usr/bin/$BINARY
|
|
|
|
|
|
|
|
VOLUME /mnt
|
2020-06-15 02:41:45 +00:00
|
|
|
WORKDIR /opt/pictrs
|
2020-06-07 20:21:25 +00:00
|
|
|
USER pictrs
|
|
|
|
EXPOSE 8080
|
2020-06-16 00:35:39 +00:00
|
|
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
|
|
|
CMD ["/usr/bin/pict-rs", "-p", "/mnt", "-a", "0.0.0.0:8080"]
|