mirror of
https://git.asonix.dog/asonix/pict-rs.git
synced 2024-11-03 16:19:35 +00:00
92 lines
1.8 KiB
Docker
92 lines
1.8 KiB
Docker
# cross-build environment
|
|
FROM rustembedded/cross:aarch64-unknown-linux-musl AS aarch64-builder
|
|
|
|
ARG UID=991
|
|
ARG GID=991
|
|
|
|
ENV \
|
|
TOOLCHAIN=stable \
|
|
TARGET=aarch64-unknown-linux-musl \
|
|
TOOL=aarch64-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 aarch64-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/aarch64-unknown-linux-musl/$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"]
|