pict-rs/docker/prod/Dockerfile.arm32v7

93 lines
1.8 KiB
Docker
Raw Normal View History

2021-08-28 22:50:56 +00:00
# cross-build environment
FROM rustembedded/cross:arm-unknown-linux-musleabihf AS arm32v7-builder
2020-10-11 01:27:57 +00:00
2021-08-28 22:50:56 +00:00
ARG UID=991
ARG GID=991
2020-10-11 01:27:57 +00:00
ENV \
2021-08-28 22:50:56 +00:00
TOOLCHAIN=stable \
TARGET=arm-unknown-linux-musleabihf \
TOOL=arm-linux-musleabihf \
2020-10-11 01:27:57 +00:00
BUILD_MODE=release
2021-08-28 22:50:56 +00:00
RUN \
apt-get update && \
apt-get upgrade -y
2020-10-11 01:27:57 +00:00
RUN \
2021-08-28 22:50:56 +00:00
addgroup --gid "${GID}" build && \
2020-10-11 01:27:57 +00:00
adduser \
--disabled-password \
--gecos "" \
--ingroup build \
2021-08-28 22:50:56 +00:00
--uid "${UID}" \
2020-10-11 01:27:57 +00:00
--home /opt/build \
2021-08-28 22:50:56 +00:00
build
2020-10-11 01:27:57 +00:00
2021-08-28 22:50:56 +00:00
ADD https://sh.rustup.rs /opt/build/rustup.sh
2020-10-11 01:27:57 +00:00
RUN \
2021-08-28 22:50:56 +00:00
chown -R build:build /opt/build
2020-10-11 01:27:57 +00:00
USER build
2021-08-28 22:50:56 +00:00
WORKDIR /opt/build
2020-10-11 01:27:57 +00:00
2021-08-28 22:50:56 +00:00
ENV PATH=/opt/build/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2020-10-11 01:27:57 +00:00
RUN \
chmod +x rustup.sh && \
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
rustup target add $TARGET
2021-08-28 22:50:56 +00:00
# build script
FROM arm32v7-builder as builder
2020-10-11 01:27:57 +00:00
ARG TAG=main
ARG GIT_REPOSITORY=https://git.asonix.dog/asonix/pict-rs
2021-08-28 22:50:56 +00:00
ARG BINARY=pict-rs
2020-10-11 01:27:57 +00:00
2021-08-28 22:50:56 +00:00
ADD \
--chown=build:build \
$GIT_REPOSITORY/archive/$TAG.tar.gz \
/opt/build/$TAG.tar.gz
2020-10-11 01:27:57 +00:00
USER build
RUN \
tar zxf $TAG.tar.gz
WORKDIR /opt/build/pict-rs
RUN \
2021-08-28 22:55:54 +00:00
USER=build cargo build --target $TARGET --$BUILD_MODE && \
2021-08-28 22:50:56 +00:00
$TOOL-strip target/$TARGET/$BUILD_MODE/$BINARY
2020-10-11 01:27:57 +00:00
2021-08-28 22:50:56 +00:00
# production environment
FROM amd64/alpine:3.14
2020-10-11 01:27:57 +00:00
ARG UID=991
ARG GID=991
2021-08-28 22:50:56 +00:00
ARG BINARY=pict-rs
2021-08-28 22:55:54 +00:00
ARG BUILD_MODE=release
2020-10-11 01:27:57 +00:00
2021-08-28 22:50:56 +00:00
COPY --from=builder \
2021-08-28 22:55:54 +00:00
/opt/build/pict-rs/target/arm-unknown-linux-musleabihf/$BUILD_MODE/$BINARY \
2021-08-28 22:50:56 +00:00
/usr/local/bin/$BINARY
2020-10-11 01:27:57 +00:00
2021-08-28 22:50:56 +00:00
RUN \
apk add tini ffmpeg imagemagick exiv2 && \
addgroup -g $GID pictrs && \
adduser -D -G pictrs -u $UID -g "" -h /opt/pict-rs pictrs
2020-10-11 01:27:57 +00:00
RUN \
2021-08-28 22:50:56 +00:00
chown -R pictrs:pictrs /mnt
2020-10-11 01:27:57 +00:00
COPY root/ /
2020-10-11 01:27:57 +00:00
VOLUME /mnt
WORKDIR /opt/pict-rs
USER pictrs
EXPOSE 8080
2021-08-28 22:50:56 +00:00
ENTRYPOINT ["/sbin/tini", "--"]
2020-10-11 01:27:57 +00:00
CMD ["/usr/local/bin/pict-rs", "-p", "/mnt"]