Skip to content

Commit 41911e5

Browse files
devcontainer setup (#4)
1 parent 5bd1dc5 commit 41911e5

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

.devcontainer/Dockerfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
################################################################################
2+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
################################################################################
13+
14+
FROM mcr.microsoft.com/devcontainers/rust:latest
15+
16+
ARG USERNAME=vscode
17+
ARG TARGETARCH
18+
19+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
20+
&& apt-get -y install \
21+
# Others
22+
curl \
23+
zip \
24+
gcc \
25+
git \
26+
&& \
27+
rm -rf /var/lib/apt/lists/*
28+
29+
# Before installing cargo tools, change to the user that will be used in the container later.
30+
# The reason is that cargo creates some cache, etc. folders with the correct group rustlang, but
31+
# without making them group writable. Easiest fix is to change to the correct user before the install,
32+
# so that the owner is correct from the start.
33+
USER ${USERNAME}
34+
35+
# Install cargo cli tools
36+
RUN cargo install cargo-nextest cargo-deny cargo-tarpaulin cargo-dist --locked
37+
38+
# Install cargo tools for cross compilation
39+
RUN rustup target add aarch64-unknown-linux-gnu \
40+
&& rustup toolchain install stable-aarch64-unknown-linux-gnu

.devcontainer/devcontainer.json

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
3+
{
4+
"name": "uProtocol-USubscription rust",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
"runArgs": [
9+
"--privileged"
10+
],
11+
// This is a workaround which is again necessary on MacOS 14.0, it looks like this bug is back:
12+
// https://github.com/microsoft/vscode-dev-containers/issues/1487#issuecomment-1143907307
13+
"mounts": [
14+
"source=rust-volume,target=/rust-volume,type=volume"
15+
],
16+
"postCreateCommand": "sudo .devcontainer/post-create.sh",
17+
"customizations": {
18+
"vscode": {
19+
// Set *default* container specific settings.json values on container create.
20+
"settings": {
21+
"lldb.executable": "/usr/bin/lldb",
22+
// VS Code don't watch files under ./target
23+
"files.watcherExclude": {
24+
"**/target/**": true
25+
},
26+
"rust-analyzer.checkOnSave.command": "clippy",
27+
"coverage-gutters.coverageBaseDir": "**",
28+
"coverage-gutters.coverageFileNames": [
29+
"target/tarpaulin/lcov.info"
30+
]
31+
},
32+
// Add the IDs of extensions you want installed when the container is created.
33+
"extensions": [
34+
"asciidoctor.asciidoctor-vscode",
35+
"bianxianyang.htmlplay",
36+
"bierner.markdown-mermaid",
37+
"bierner.markdown-preview-github-styles",
38+
"davidanson.vscode-markdownlint",
39+
"hediet.vscode-drawio",
40+
"linusu.auto-dark-mode",
41+
"mhutchie.git-graph",
42+
"ryanluker.vscode-coverage-gutters",
43+
"rust-lang.rust-analyzer",
44+
"streetsidesoftware.code-spell-checker",
45+
"tamasfe.even-better-toml",
46+
"timonwong.shellcheck",
47+
"vadimcn.vscode-lldb",
48+
"yzhang.markdown-all-in-one",
49+
"zxh404.vscode-proto3"
50+
]
51+
}
52+
},
53+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/up-subscription-rust/,type=bind",
54+
"workspaceFolder": "/workspace/up-subscription-rust/",
55+
"remoteUser": "vscode"
56+
}

.devcontainer/post-create.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# This is a workaround which is againt necessary on MacOS 14.0, it looks like this bug is back:
4+
# https://github.com/microsoft/vscode-dev-containers/issues/1487#issuecomment-1143907307
5+
6+
# grant permissions to mounted rust volume
7+
chown vscode:vscode /rust-volume
8+
9+
# create /.cargo/config.toml in root folder
10+
mkdir /.cargo/
11+
touch /.cargo/config.toml
12+
cat <<EOF >/.cargo/config.toml
13+
[build]
14+
target-dir = "/rust-volume/target"
15+
EOF

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ This codebase is heavily work in progress - among the next things to do and inve
1010
- [x] make size of command channels bounded and (probably) configurable
1111
- [x] handling of startup and proper shutdown for usubscription service
1212
- [ ] look into recent up-rust changes around Rpc and UTransport implementations, and whether we can use something from there
13-
- [ ] add github CI pipeline setup
13+
- [x] add github CI pipeline setup
1414
- [x] create a usubscription-cli module, a simple command-line frontend for running up-subscription
1515
- [ ] create a little demo application for interacting with up-subscription
16-
- [ ] set up a devcontainer
16+
- [x] set up a devcontainer
1717
- [ ] feed back learnings and clarifications into up-spec usubscription documentation
1818

1919
## Implementation questions

0 commit comments

Comments
 (0)