Allow compiling with Rust code (#3137)
Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com> Co-authored-by: Ian Wagner <ianwagner+github@switzerlandmail.ch>
This commit is contained in:
@@ -23,12 +23,16 @@ RUN apt-get update \
|
||||
ccache \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python-is-python3 \
|
||||
clang-tidy \
|
||||
&& : # end of the RUN cmd - easier to keep a colon at the end of the list, than to keep the backslashes in check
|
||||
|
||||
# This could also be `.../releases/latest/download/bazelisk-linux-amd64` for the latest version, but for predictability better hardcode it
|
||||
# Detect if current CPU is x64 or ARM64 and download the appropriate binary
|
||||
RUN if [ "$(uname -m)" = "aarch64" ]; then \
|
||||
RUN echo "Download and install Bazel" \
|
||||
&& if [ "$(uname -m)" = "aarch64" ]; then \
|
||||
curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-arm64 -o /usr/local/bin/bazel ;\
|
||||
else \
|
||||
curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64 -o /usr/local/bin/bazel ;\
|
||||
@@ -36,7 +40,6 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \
|
||||
&& chmod +x /usr/local/bin/bazel \
|
||||
&& :
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ARG USERNAME=user
|
||||
ARG USER_UID=1000
|
||||
@@ -50,11 +53,21 @@ RUN groupadd --force --gid $USER_GID $USERNAME \
|
||||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
|
||||
&& chmod 0440 /etc/sudoers.d/$USERNAME
|
||||
|
||||
COPY startup.sh /usr/local/bin/startup.sh
|
||||
RUN chmod +x /usr/local/bin/startup.sh
|
||||
|
||||
# This allows users to `docker run` without specifying -u and -g
|
||||
USER $USERNAME
|
||||
|
||||
RUN pip install pre-commit
|
||||
|
||||
ENV RUSTUP_HOME=/home/$USERNAME/.cache/.rustup \
|
||||
CARGO_HOME=/home/$USERNAME/.cache/.cargo \
|
||||
PATH=/home/$USERNAME/.cache/.cargo/bin:$PATH
|
||||
|
||||
# As the very last step, copy the startup script
|
||||
USER root
|
||||
COPY startup.sh /usr/local/bin/startup.sh
|
||||
RUN chmod +x /usr/local/bin/startup.sh
|
||||
USER $USERNAME
|
||||
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["/usr/local/bin/startup.sh"]
|
||||
CMD ["bash"]
|
||||
|
||||
@@ -1,13 +1,51 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -d /app/.github ] || [ ! -d /home/user/.cache ]; then
|
||||
if [ ! -d /app/.github ] || [ ! -d ~/.cache ]; then
|
||||
echo " "
|
||||
echo "ERROR: Docker container was not started properly."
|
||||
echo " From the root of this repo, run the following command."
|
||||
echo " You may add any command to perform in the container at the end of this command."
|
||||
echo " "
|
||||
echo ' docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/user/.cache" maplibre-native-image'
|
||||
echo ' docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/'"$USERNAME"'/.cache" maplibre-native-image'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export PATH="$PATH:~/.local/bin/"
|
||||
|
||||
|
||||
# Work in progress: install and configure Swift and pre-commit
|
||||
# Detect if current CPU is x64 or ARM64 and download the appropriate binary
|
||||
#RUN echo "Download and install SWIFT" \
|
||||
# && if [ "$(uname -m)" = "aarch64" ]; then \
|
||||
# curl -fsSL https://download.swift.org/swift-5.10.1-release/ubuntu2204-aarch64/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-ubuntu22.04-aarch64.tar.gz \
|
||||
# -o /tmp/swift.tar.gz ;\
|
||||
# else \
|
||||
# curl -fsSL https://download.swift.org/swift-5.10.1-release/ubuntu2204/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-ubuntu22.04.tar.gz \
|
||||
# -o /tmp/swift.tar.gz ;\
|
||||
# fi \
|
||||
# && tar -xzf /tmp/swift.tar.gz -C / --strip-components=1 \
|
||||
# && rm /tmp/swift.tar.gz \
|
||||
# && :
|
||||
#if [ ! -f "/app/.git/hooks/pre-commit" ]; then
|
||||
# echo "Configuring pre-commit git hooks by creating a .git/hooks/pre-commit file..."
|
||||
# ~/.local/bin/pre-commit install
|
||||
#fi
|
||||
|
||||
|
||||
|
||||
if [ ! -f "$CARGO_HOME/env" ]; then
|
||||
echo "Downloading and installing Rust..."
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
||||
fi
|
||||
. "$CARGO_HOME/env"
|
||||
|
||||
|
||||
|
||||
if ! command -v cxxbridge > /dev/null; then
|
||||
echo "Installing cxxbridge..."
|
||||
cargo install cxxbridge-cmd
|
||||
fi
|
||||
|
||||
|
||||
|
||||
exec "$@"
|
||||
|
||||
Reference in New Issue
Block a user