pict-rs/docker/prod/Dockerfile.arm64v8

93 lines
1.8 KiB
Docker
Raw Normal View History

2021-08-28 22:50:56 +00:00
# cross-build environment
FROM rustembedded/cross:aarch64-unknown-linux-musl AS aarch64-builder
2020-06-16 20:55:24 +00:00
2021-08-28 22:50:56 +00:00
ARG UID=991
ARG GID=991
2020-06-16 20:55:24 +00:00
ENV \
2021-08-28 22:50:56 +00:00
TOOLCHAIN=stable \
TARGET=aarch64-unknown-linux-musl \
TOOL=aarch64-linux-musl \
2020-06-16 20:55:24 +00:00
BUILD_MODE=release
2021-08-28 22:50:56 +00:00
RUN \
apt-get update && \
apt-get upgrade -y
2020-06-07 23:29:41 +00:00
RUN \
2021-08-28 22:50:56 +00:00
addgroup --gid "${GID}" build && \
2020-06-07 23:29:41 +00:00
adduser \
--disabled-password \
--gecos "" \
--ingroup build \
2021-08-28 22:50:56 +00:00
--uid "${UID}" \
2020-06-07 23:29:41 +00:00
--home /opt/build \
2021-08-28 22:50:56 +00:00
build
2020-06-07 23:29:41 +00:00
2021-08-28 22:50:56 +00:00
ADD https://sh.rustup.rs /opt/build/rustup.sh
2020-06-15 19:20:25 +00:00
2020-06-15 02:41:45 +00:00
RUN \
2021-08-28 22:50:56 +00:00
chown -R build:build /opt/build
2020-06-15 19:20:25 +00:00
USER build
2021-08-28 22:50:56 +00:00
WORKDIR /opt/build
2020-06-15 19:20:25 +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-06-08 17:43:28 +00:00
2020-06-07 23:29:41 +00:00
RUN \
2020-06-16 20:55:24 +00:00
chmod +x rustup.sh && \
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
rustup target add $TARGET
2020-06-07 23:29:41 +00:00
2021-08-28 22:50:56 +00:00
# build script
FROM aarch64-builder as builder
2020-06-16 20:55:24 +00:00
2020-06-18 15:01:21 +00:00
ARG TAG=main
2020-06-16 20:55:24 +00:00
ARG GIT_REPOSITORY=https://git.asonix.dog/asonix/pict-rs
2021-08-28 22:50:56 +00:00
ARG BINARY=pict-rs
2020-06-16 20:55:24 +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-06-16 20:55:24 +00:00
USER build
2020-06-16 00:35:39 +00:00
2020-06-07 23:29:41 +00:00
RUN \
2020-06-16 20:55:24 +00:00
tar zxf $TAG.tar.gz
2020-06-07 23:29:41 +00:00
2020-06-16 20:55:24 +00:00
WORKDIR /opt/build/pict-rs
RUN \
2021-08-28 22:56:22 +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-06-16 20:55:24 +00:00
2021-08-28 22:50:56 +00:00
# production environment
2021-08-29 04:15:29 +00:00
FROM arm64v8/alpine:3.14
2020-06-07 23:29:41 +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-06-07 23:29:41 +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/aarch64-unknown-linux-musl/$BUILD_MODE/$BINARY \
2021-08-28 22:50:56 +00:00
/usr/local/bin/$BINARY
2020-06-08 01:28:16 +00:00
2021-08-28 22:50:56 +00:00
RUN \
2021-08-31 16:19:44 +00:00
apk add tini ffmpeg imagemagick exiftool && \
2021-08-28 22:50:56 +00:00
addgroup -g $GID pictrs && \
adduser -D -G pictrs -u $UID -g "" -h /opt/pict-rs pictrs
2020-06-28 22:19:55 +00:00
RUN \
2021-08-28 22:50:56 +00:00
chown -R pictrs:pictrs /mnt
2020-06-16 00:35:39 +00:00
COPY root/ /
2020-06-08 14:12:12 +00:00
VOLUME /mnt
2020-06-16 20:55:24 +00:00
WORKDIR /opt/pict-rs
2020-06-07 23:29:41 +00:00
USER pictrs
2020-06-16 00:35:39 +00:00
EXPOSE 8080
2021-08-28 22:50:56 +00:00
ENTRYPOINT ["/sbin/tini", "--"]
2020-06-16 20:55:24 +00:00
CMD ["/usr/local/bin/pict-rs", "-p", "/mnt"]