rust-builder/Dockerfile

63 lines
1.1 KiB
Docker
Raw Normal View History

2021-12-22 21:43:39 +00:00
ARG TARGET
2021-09-06 18:44:02 +00:00
# build environment
2022-07-22 04:28:23 +00:00
FROM ghcr.io/cross-rs/$TARGET:latest
2021-09-06 18:44:02 +00:00
RUN \
apt update && \
apt upgrade -y && \
2022-09-21 03:19:10 +00:00
apt install -y libclang-dev protobuf-compiler
2021-09-06 18:44:02 +00:00
ARG UID=991
ARG GID=991
2021-12-22 21:43:39 +00:00
ARG TARGET
ARG TOOL
2021-09-06 18:44:02 +00:00
ARG BUILD_MODE=release
ENV \
2021-12-22 21:43:39 +00:00
UID=${UID} \
GID=${GID} \
TARGET=${TARGET} \
TOOL=${TOOL} \
BUILD_MODE=${BUILD_MODE} \
TOOLCHAIN=stable \
CC=${TOOL}-cc \
CXX=${TOOL}-c++ \
BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/usr/local/$TOOL/ --target=$TARGET -L/usr/local/$TOOL/lib -I/usr/local/$TOOL/include --static -static-libgcc -static-libstdc++" \
2022-01-09 06:01:23 +00:00
HOST_CC=cc
2021-09-06 18:44:02 +00:00
RUN \
2021-12-22 21:43:39 +00:00
addgroup --gid "${GID}" build && \
adduser \
--disabled-password \
--gecos "" \
--ingroup build \
--uid "${UID}" \
--home /opt/build \
build
2021-09-06 18:44:02 +00:00
ADD \
2021-12-22 21:43:39 +00:00
https://sh.rustup.rs /opt/build/rustup.sh
2021-09-06 18:44:02 +00:00
RUN \
2021-12-22 21:43:39 +00:00
chown -R build:build /opt/build
2021-09-06 18:44:02 +00:00
USER build
WORKDIR /opt/build
ENV \
2021-12-22 21:43:39 +00:00
PATH=/opt/build/.cargo/bin:/usr/local/musl/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin
2021-09-06 18:44:02 +00:00
RUN \
2021-12-22 21:43:39 +00:00
chmod +x rustup.sh && \
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
rustup target add $TARGET
2021-09-06 18:44:02 +00:00
USER build
WORKDIR /opt/build/
2021-09-06 18:53:21 +00:00
COPY root/ /
2021-09-06 18:44:02 +00:00
CMD /usr/bin/bash