2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-10 06:25:00 +00:00
pict-rs/docker/prod/Dockerfile.arm32v7

92 lines
1.8 KiB
Text

# cross-build environment
FROM rustembedded/cross:arm-unknown-linux-musleabihf AS arm32v7-builder
ARG UID=991
ARG GID=991
ENV \
TOOLCHAIN=stable \
TARGET=arm-unknown-linux-musleabihf \
TOOL=arm-linux-musleabihf \
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 arm32v7-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 arm32v7/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/arm-unknown-linux-musleabihf/$BUILD_MODE/$BINARY \
/usr/local/bin/$BINARY
RUN \
apk add tini ffmpeg imagemagick exiv2 && \
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"]