-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add Docker-based development environment
- Loading branch information
Showing
13 changed files
with
125 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,2 @@ | ||
[alias] | ||
xtask = "run --package xtask --" | ||
|
||
[target.x86_64-unknown-linux-gnu] | ||
linker = "x86_64-linux-gnu-gcc" | ||
|
||
[target.arm-unknown-linux-musleabihf] | ||
linker = "arm-linux-gnueabihf-gcc" | ||
|
||
[target.aarch64-unknown-linux-musl] | ||
linker = "aarch64-linux-gnu-gcc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
!cargo xtask | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
DOCKER=${DOCKER:-"docker"} | ||
|
||
COMPOSE_FILE="./xtask/devenv/compose.yml" | ||
|
||
if [ $($DOCKER compose --file "$COMPOSE_FILE" ps -q | wc -l) -gt 0 ]; then | ||
echo "Development environment is already running." | ||
else | ||
echo "Starting development environment." | ||
$DOCKER compose --file "$COMPOSE_FILE" up --build -d | ||
fi | ||
|
||
if [ "${1:-}" = "devenv" ]; then | ||
shift | ||
exec $DOCKER compose \ | ||
--file ./xtask/devenv/compose.yml \ | ||
"$@" | ||
fi | ||
|
||
if [ "${1:-}" = "shell" ]; then | ||
exec $DOCKER compose \ | ||
--file ./xtask/devenv/compose.yml \ | ||
exec --privileged devenv "/project/xtask/devenv/run.sh" zsh | ||
fi | ||
|
||
exec $DOCKER compose \ | ||
--file ./xtask/devenv/compose.yml \ | ||
exec --privileged devenv "/project/xtask/devenv/run.sh" cargo xtask "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM rust:latest | ||
|
||
COPY xtask/devenv/setup.sh . | ||
|
||
RUN ./setup.sh && rm -f ./setup.sh | ||
|
||
WORKDIR /project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: rugpi | ||
|
||
services: | ||
devenv: | ||
build: | ||
context: ../../ | ||
dockerfile: xtask/devenv/Dockerfile | ||
environment: | ||
- CARGO_HOME=/tmp/.cargo | ||
- CARGO_TARGET_DIR=/tmp/target | ||
volumes: | ||
- ../../:/project | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
entrypoint: "sleep infinity" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
export CC_x86_64_unknown_linux_musl=x86_64-linux-gnu-gcc | ||
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld" | ||
|
||
export CC_aarch64_unknown_linux_musl=aarch64-linux-gnu-gcc | ||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld" | ||
|
||
export CC_arm_unknown_linux_musleabihf=arm-linux-gnueabihf-gcc | ||
export CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld" | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
HOST_ARCH=$(dpkg --print-architecture) | ||
|
||
echo "Host Architecture: ${HOST_ARCH}" | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
apt-get -y update | ||
|
||
apt-get -y install \ | ||
build-essential \ | ||
curl \ | ||
file \ | ||
git \ | ||
python3 \ | ||
python3-pip \ | ||
wget \ | ||
zsh | ||
|
||
wget -O /etc/zsh/zshrc https://git.grml.org/f/grml-etc-core/etc/zsh/zshrc | ||
touch /root/.zshrc | ||
|
||
case "${HOST_ARCH}" in | ||
"arm64") | ||
apt-get -y install gcc-x86-64-linux-gnu libc6-dev-amd64-cross | ||
;; | ||
"amd64") | ||
apt-get -y install gcc-aarch64-linux-gnu libc6-dev-arm64-cross | ||
;; | ||
*) | ||
echo "Error: Unsupported architecture \`${HOST_ARCH}\`." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Add `armhf` toolchain regardless of host architecture. | ||
apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross | ||
|
||
apt-get install -y musl-tools clang pkg-config docker.io | ||
|
||
apt-get -y clean && rm -rf /var/lib/apt/lists/* | ||
|
||
rustup target add arm-unknown-linux-musleabihf | ||
rustup target add aarch64-unknown-linux-musl | ||
rustup target add x86_64-unknown-linux-musl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters