Skip to content

Add devcontainer setup #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
################################################################################
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
################################################################################

FROM mcr.microsoft.com/devcontainers/rust:latest

ARG USERNAME=vscode
ARG TARGETARCH

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install \
# Others
curl \
zip \
gcc \
git \
&& \
rm -rf /var/lib/apt/lists/*

# Before installing cargo tools, change to the user that will be used in the container later.
# The reason is that cargo creates some cache, etc. folders with the correct group rustlang, but
# without making them group writable. Easiest fix is to change to the correct user before the install,
# so that the owner is correct from the start.
USER ${USERNAME}

# Install cargo cli tools
RUN cargo install cargo-nextest cargo-deny cargo-tarpaulin cargo-dist --locked

# Install cargo tools for cross compilation
RUN rustup target add aarch64-unknown-linux-gnu \
&& rustup toolchain install stable-aarch64-unknown-linux-gnu
56 changes: 56 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
{
"name": "uProtocol-USubscription rust",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--privileged"
],
// This is a workaround which is again necessary on MacOS 14.0, it looks like this bug is back:
// https://github.com/microsoft/vscode-dev-containers/issues/1487#issuecomment-1143907307
"mounts": [
"source=rust-volume,target=/rust-volume,type=volume"
],
"postCreateCommand": "sudo .devcontainer/post-create.sh",
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy",
"coverage-gutters.coverageBaseDir": "**",
"coverage-gutters.coverageFileNames": [
"target/tarpaulin/lcov.info"
]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"asciidoctor.asciidoctor-vscode",
"bianxianyang.htmlplay",
"bierner.markdown-mermaid",
"bierner.markdown-preview-github-styles",
"davidanson.vscode-markdownlint",
"hediet.vscode-drawio",
"linusu.auto-dark-mode",
"mhutchie.git-graph",
"ryanluker.vscode-coverage-gutters",
"rust-lang.rust-analyzer",
"streetsidesoftware.code-spell-checker",
"tamasfe.even-better-toml",
"timonwong.shellcheck",
"vadimcn.vscode-lldb",
"yzhang.markdown-all-in-one",
"zxh404.vscode-proto3"
]
}
},
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/up-subscription-rust/,type=bind",
"workspaceFolder": "/workspace/up-subscription-rust/",
"remoteUser": "vscode"
}
15 changes: 15 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# This is a workaround which is againt necessary on MacOS 14.0, it looks like this bug is back:
# https://github.com/microsoft/vscode-dev-containers/issues/1487#issuecomment-1143907307

# grant permissions to mounted rust volume
chown vscode:vscode /rust-volume

# create /.cargo/config.toml in root folder
mkdir /.cargo/
touch /.cargo/config.toml
cat <<EOF >/.cargo/config.toml
[build]
target-dir = "/rust-volume/target"
EOF
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ This codebase is heavily work in progress - among the next things to do and inve
- [x] make size of command channels bounded and (probably) configurable
- [x] handling of startup and proper shutdown for usubscription service
- [ ] look into recent up-rust changes around Rpc and UTransport implementations, and whether we can use something from there
- [ ] add github CI pipeline setup
- [x] add github CI pipeline setup
- [x] create a usubscription-cli module, a simple command-line frontend for running up-subscription
- [ ] create a little demo application for interacting with up-subscription
- [ ] set up a devcontainer
- [x] set up a devcontainer
- [ ] feed back learnings and clarifications into up-spec usubscription documentation

## Implementation questions
Expand Down