mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-14 16:33:57 +00:00
92 lines
1.7 KiB
Text
92 lines
1.7 KiB
Text
# cross-build environment
|
|
FROM rustembedded/cross:x86_64-unknown-linux-musl AS x86_64-builder
|
|
|
|
ARG UID=991
|
|
ARG GID=991
|
|
|
|
ENV \
|
|
TOOLCHAIN=stable \
|
|
TARGET=x86_64-unknown-linux-musl \
|
|
TOOL=x86_64-linux-musl \
|
|
BUILD_MODE=release
|
|
|
|
RUN \
|
|
apt-get update && \
|
|
apt-get upgrade -y
|
|
|
|
RUN \
|
|
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
|
|
|
|
ENV PATH=/opt/build/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
RUN \
|
|
chmod +x rustup.sh && \
|
|
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
|
|
rustup target add $TARGET
|
|
|
|
# build script
|
|
FROM x86_64-builder as builder
|
|
|
|
ARG TAG=main
|
|
ARG GIT_REPOSITORY=https://git.asonix.dog/asonix/pict-rs
|
|
ARG BINARY=pict-rs
|
|
|
|
ADD \
|
|
--chown=build:build \
|
|
$GIT_REPOSITORY/archive/$TAG.tar.gz \
|
|
/opt/build/$TAG.tar.gz
|
|
|
|
USER build
|
|
|
|
RUN \
|
|
tar zxf $TAG.tar.gz
|
|
|
|
WORKDIR /opt/build/pict-rs
|
|
|
|
RUN \
|
|
USER=build cargo build --target $TARGET --$BUILD_MODE && \
|
|
$TOOL-strip target/$TARGET/$BUILD_MODE/$BINARY
|
|
|
|
# production environment
|
|
FROM amd64/alpine:3.14
|
|
|
|
ARG UID=991
|
|
ARG GID=991
|
|
ARG BINARY=pict-rs
|
|
ARG BUILD_MODE=release
|
|
|
|
COPY --from=builder \
|
|
/opt/build/pict-rs/target/x86_64-unknown-linux-musl/$BUILD_MODE/$BINARY \
|
|
/usr/local/bin/$BINARY
|
|
|
|
RUN \
|
|
apk add tini ffmpeg imagemagick exiftool && \
|
|
addgroup -g $GID pictrs && \
|
|
adduser -D -G pictrs -u $UID -g "" -h /opt/pict-rs pictrs
|
|
|
|
RUN \
|
|
chown -R pictrs:pictrs /mnt
|
|
|
|
COPY root/ /
|
|
|
|
VOLUME /mnt
|
|
WORKDIR /opt/pict-rs
|
|
USER pictrs
|
|
EXPOSE 8080
|
|
ENTRYPOINT ["/sbin/tini", "--"]
|
|
CMD ["/usr/local/bin/pict-rs", "-p", "/mnt"]
|