-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add devcontainer setup and contribution guide
- Loading branch information
Showing
9 changed files
with
164 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM dev:rust | ||
|
||
USER root | ||
|
||
RUN rustup component add rustfmt clippy && \ | ||
rustup target add x86_64-pc-windows-gnu && \ | ||
apk add --no-cache mingw-w64-gcc musl-dev && \ | ||
ln -s /usr/x86_64-w64-mingw32/lib/liboleaut32.a /usr/x86_64-w64-mingw32/lib/libOleAut32.a | ||
|
||
RUN apk update && apk add --no-cache nodejs npm | ||
|
||
RUN npm i -g yarn | ||
|
||
USER rust |
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,66 @@ | ||
{ | ||
"name": "${containerWorkspaceFolderBasename}", | ||
"dockerFile": "Dockerfile", | ||
"remoteEnv": { | ||
"WSL_HOST_IP": "${localEnv:WSL_HOST_IP}", | ||
"WSL_IP": "${localEnv:WSL_IP}" | ||
}, | ||
"runArgs": [ | ||
"--env-file", | ||
"${localWorkspaceFolder}/.env" | ||
], | ||
"mounts": [ | ||
"type=bind,src=${localWorkspaceFolder}/.devcontainer/fish-history,dst=/home/rust/.local/share/fish", | ||
"type=bind,src=${localEnv:HOME}/.blueprints,dst=/home/rust/.blueprints", | ||
"type=bind,src=${localEnv:HOME}/.ssh,dst=/home/rust/.ssh,readonly", | ||
"type=volume,src=rust-global-cache,dst=/usr/local/cargo/registry", | ||
"type=volume,src=yarn-global-cache,dst=/home/rust/.yarn/berry/cache", | ||
// DEBUG: for debug purpose only | ||
"type=bind,src=${localWorkspaceFolder}/../mystic-light-sdk,dst=/workspaces/mystic-light-sdk" | ||
], | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
// common | ||
"alefragnani.bookmarks", | ||
"orepor.color-tabs-vscode-ext", | ||
"rudijansenvanvuuren.blueprints", | ||
"naumovs.color-highlight", | ||
"EditorConfig.EditorConfig", | ||
"vscode-snippet.Snippet", | ||
// md | ||
"yzhang.markdown-all-in-one", | ||
"hediet.vscode-drawio", | ||
// yaml | ||
"redhat.vscode-yaml", | ||
// string | ||
"qcz.text-power-tools", | ||
"britesnow.vscode-toggle-quotes", | ||
// git | ||
"eamodio.gitlens", | ||
"mhutchie.git-graph", | ||
"vivaxy.vscode-conventional-commits", | ||
// spell checker | ||
"streetsidesoftware.code-spell-checker", | ||
"streetsidesoftware.code-spell-checker-russian", | ||
// debug | ||
"hediet.debug-visualizer", | ||
// rust | ||
"rust-lang.rust-analyzer", | ||
"serayuzgur.crates", | ||
"vadimcn.vscode-lldb", | ||
"bungcip.better-toml", | ||
// js-ts | ||
"dbaeumer.vscode-eslint" | ||
], | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "sudo chown rust /usr/local/cargo/registry && sudo chown rust /home/rust/.yarn/berry", | ||
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. | ||
// "remoteUser": "node" | ||
"containerEnv": { | ||
"CONTAINER_PROJECT_HOME": "${containerWorkspaceFolder}", | ||
"HOST_PROJECT_HOME": "${localWorkspaceFolder}", | ||
"MYSTIC_LIGHT_SDK_PATH": "${containerWorkspaceFolder}/native-app/sdk" | ||
} | ||
} |
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,12 @@ | ||
#! /usr/bin/env fish | ||
|
||
echo "Run any cargo command" | ||
|
||
while true | ||
set path (cat .devcontainer/command-pipe) | ||
|
||
kill %1 | ||
reset | ||
|
||
eval "RUST_BACKTRACE=1 $path &" | ||
end |
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,3 @@ | ||
#! /usr/bin/env fish | ||
|
||
echo (string replace $CONTAINER_PROJECT_HOME $HOST_PROJECT_HOME (realpath $argv)) > ../.devcontainer/command-pipe |
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 @@ | ||
{ | ||
"search.exclude": { | ||
"**/.yarn": true, | ||
"**/.pnp.*": true | ||
}, | ||
"eslint.nodePath": "chrome-extension/.yarn/sdks", | ||
"prettier.prettierPath": "chrome-extension/.yarn/sdks/prettier/index.js", | ||
"typescript.tsdk": "chrome-extension/.yarn/sdks/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"conventionalCommits.scopes": [ | ||
"native-app", | ||
"chrome-extension" | ||
] | ||
} |
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,51 @@ | ||
# Contributing | ||
|
||
Make sure you have Rust toolchain installed | ||
|
||
## Setup | ||
|
||
## Linux | ||
|
||
**You won't be able to execute program or run tests as sdk supports only windows** | ||
|
||
1. Add windows target `rustup target add x86_64-pc-windows-gnu` | ||
2. Add MinGW (e.g. for the alpine `apk add mingw-w64-gcc`) | ||
3. Specify target by env `CARGO_BUILD_TARGET=x86_64-pc-windows-gnu` | ||
|
||
You can now build some of the bin using `cargo build --bin app`, but you have to run it on any other windows machine with the Dragon Center installed. | ||
|
||
|
||
## Windows | ||
|
||
Should work without any hassle. | ||
|
||
Run `cargo run` to run app server | ||
|
||
### WSL 2 | ||
|
||
There is a catch - wsl 2 runs in linux environment, but it still can run windows executable, so we can use WSL 2 linux environment to build actual program and then run built .exe file | ||
|
||
1. Install additional libs to able to build windows app following [linux instructions](#linux) | ||
2. Open WSL2 Terminal as Administrator | ||
3. Go to `native-app` directory | ||
4. Run `cargo run` | ||
|
||
|
||
### WSL 2 + Docker | ||
|
||
If you are using Rust inside Docker container you not able to run .exe files from inside it, but you can use named pipe to pass commands to the host WSL 2 instance that able to run .exe | ||
|
||
For this either use Remote Containers extension with the provided `.devcontainer` setup or follow next instruction: | ||
|
||
1. Install additional libs to able to build windows app following [linux instructions](#linux) | ||
2. Mount existing named pipe and scripts to the docker container `type=bind,src=${localWorkspaceFolder}/.devcontainer,dst=${containerWorkspaceFolder}/.devcontainer` | ||
3. Specify environment variables for container: | ||
- `CONTAINER_PROJECT_HOME` - path to the project inside the container | ||
- `HOST_PROJECT_HOME` - path to projects in WSL | ||
- `MYSTIC_LIGHT_SDK_PATH` - absolute path to `native-app/sdk` library | ||
- `CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER` - relative path to `.devcontainer/send.fish` script | ||
4. Run the container | ||
5. You can use `wsl2-docker.env` in order to fill needed environment variable that will wrap execution for the program run | ||
6. Start new WSL terminal with admin right and execute script `.devcontainer/execute.fish` that will listen for new commands and execute it | ||
7. Run `cargo run` inside the container | ||
8. Execution will end without any info, but you should see test running output in the WSL terminal |
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 @@ | ||
CARGO_BUILD_TARGET=x86_64-pc-windows-gnu |
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,2 @@ | ||
CARGO_BUILD_TARGET=x86_64-pc-windows-gnu | ||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=../.devcontainer/send.fish |
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 @@ | ||
CARGO_BUILD_TARGET=x86_64-pc-windows-gnu |