mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-25 11:01:11 +00:00
73 lines
1.4 KiB
Docker
73 lines
1.4 KiB
Docker
FROM rustembedded/cross:aarch64-unknown-linux-musl AS aarch64-builder
|
|
|
|
ARG UID=991
|
|
ARG GID=991
|
|
|
|
ENV TOOLCHAIN=stable
|
|
ENV TARGET=aarch64-unknown-linux-musl
|
|
ENV TOOL=aarch64-linux-musl
|
|
|
|
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="$PATH:/opt/build/.cargo/bin"
|
|
|
|
RUN \
|
|
chmod +x rustup.sh && \
|
|
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
|
|
rustup target add $TARGET
|
|
|
|
FROM aarch64-builder as builder
|
|
|
|
ARG TAG=master
|
|
ARG REPOSITORY=https://git.asonix.dog/asonix/relay
|
|
ARG BINARY=relay
|
|
|
|
RUN \
|
|
git clone -b $TAG $REPOSITORY repo
|
|
|
|
WORKDIR /opt/build/repo
|
|
|
|
RUN \
|
|
cargo build --release --target $TARGET && \
|
|
$TOOL-strip target/$TARGET/release/$BINARY
|
|
|
|
FROM arm64v8/alpine:3.12
|
|
|
|
ARG UID=991
|
|
ARG GID=991
|
|
ARG BINARY=relay
|
|
ARG TARGET=aarch64-unknown-linux-musl
|
|
|
|
RUN \
|
|
apk add tini && \
|
|
addgroup --gid $GID relay && \
|
|
adduser -D -G relay -u $UID -g "" -h /opt/relay relay && \
|
|
chown -R relay:relay /opt/relay
|
|
|
|
COPY --from=builder /opt/build/repo/target/$TARGET/release/$BINARY /usr/bin/$BINARY
|
|
|
|
EXPOSE 8080
|
|
WORKDIR /opt/relay
|
|
USER relay
|
|
ENTRYPOINT ["/sbin/tini", "--"]
|
|
CMD ["relay"]
|