Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

chore: update devcontainer docker image #208

Merged
merged 11 commits into from
Sep 9, 2022
26 changes: 20 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
{
"name": "Capi",
"build": {
"dockerfile": "../Dockerfile"
"dockerfile": "../Dockerfile",
"target": "vscode"
},
"settings": {
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"target/**": true
},
"dprint.path": "/home/vscode/.dprint/bin/dprint"
"[jsonc]": {
kratico marked this conversation as resolved.
Show resolved Hide resolved
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"deno.codeLens.testArgs": ["--no-check=remote", "-A", "-L=info"],
"deno.config": "./deno.jsonc",
"deno.enable": true,
"deno.lint": true,
"editor.defaultFormatter": "dprint.dprint",
"editor.formatOnSave": true,
"editor.tabSize": 2,
"prettier.printWidth": 100
},
"extensions": [
"EditorConfig.EditorConfig",
"bungcip.better-toml",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get rid of this as well, as I believe we no longer have any toml in this repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a book.toml file.
Shall I remove it anyway?

"denoland.vscode-deno",
"dprint.dprint",
"esbenp.prettier-vscode",
"rust-lang.rust-analyzer",
"ms-azuretools.vscode-docker",
"serayuzgur.crates",
"streetsidesoftware.code-spell-checker",
"vadimcn.vscode-lldb"
],
"postCreateCommand": "deno task bootstrap",
"remoteUser": "vscode"
"postCreateCommand": "deno task star"
}
4 changes: 2 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
image:
file: Dockerfile
tasks:
- init: deno task star
vscode:
extensions:
- EditorConfig.EditorConfig
- bungcip.better-toml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

- denoland.vscode-deno
- dprint.dprint
- esbenp.prettier-vscode
- matklad.rust-analyzer
- ms-azuretools.vscode-docker
- serayuzgur.crates
- streetsidesoftware.code-spell-checker
- vadimcn.vscode-lldb
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"dprint.dprint",
"esbenp.prettier-vscode",
"ms-azuretools.vscode-docker",
"serayuzgur.crates",
"streetsidesoftware.code-spell-checker",
"vadimcn.vscode-lldb"
]
Expand Down
31 changes: 21 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
FROM mcr.microsoft.com/vscode/devcontainers/rust:0-1
ARG DENO_VERSION=1.25.2

RUN rustup target add wasm32-unknown-unknown
FROM denoland/deno:${DENO_VERSION} as vscode

ENV DENO_INSTALL=/usr/local
# crates.io index update fails without this (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=918854)
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
ARG POLKADOT_VERSION=v0.9.25

RUN curl -fsSL https://deno.land/x/install/install.sh | sh
RUN curl -fsSL https://dprint.dev/install.sh | sh
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y unzip curl git \
&& curl -L -o /usr/local/bin/polkadot https://github.com/paritytech/polkadot/releases/download/${POLKADOT_VERSION}/polkadot \
&& chmod +x /usr/local/bin/polkadot \
&& curl -fsSL https://dprint.dev/install.sh | DPRINT_INSTALL=/usr/local sh \
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& npm -g install cspell@latest \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

RUN export PATH=/usr/local/cargo/bin:$PATH
RUN export DPRINT_INSTALL="/home/vscode/.dprint"
RUN export PATH="$DPRINT_INSTALL/bin:$PATH"

FROM vscode as gitpod
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitpod does not support multistage builds but VSCode devcontainer extension supports multi stage builds.

With this setup

  • gitpod, uses the last stage to configure the container image
  • devcontainer, uses the vscode stage configured in devcontainer.json


# Gitpod creates a gitpod user to run without privileges
# following https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
ENV DENO_DIR=/home/gitpod/.cache/deno
20 changes: 15 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,25 @@ for await (const event of result) {

## Environment setup

> In the future, Gitpod and dev containers will simplify spinning up a Capi development environments. The [Dockerfile](./Dockerfile), [Gitpod configuration](./.gitpod.yml) and [Dev Containers / Codespaces configuration](./.devcontainer/devcontainer.json) are in need some finessing.
### Container environment setup

Make sure you have the following installed on your machine (and please submit issues if errors crop up).
Develop in the cloud with

### System Requirements
[![Gitpod Open](https://img.shields.io/badge/Gitpod-Open-blue?logo=gitpod)](https://gitpod.io/#https://github.com/paritytech/capi)

- [Deno](https://deno.land/[email protected]/getting_started/installation)
Develop locally using the [VSCode Remote Container](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension and [Docker](https://docs.docker.com/get-docker/)

[![Open in Remote - Containers](https://img.shields.io/badge/Remote_--_Container-Open-blue?logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/paritytech/capi)

### Local environment setup

Develop on your machine installing the following (and please submit issues if errors crop up)

- [Deno](https://deno.land/manual/getting_started/installation)
- [Docker](https://docs.docker.com/get-docker/)
- [NodeJS](https://nodejs.org/) (only necessary if you're going to run [the build_npm task](./_/tasks/build_npm.ts))
- [NodeJS](https://nodejs.org/)
- [`dprint`](https://dprint.dev/)
- [`cspell`](https://cspell.org/)

### Running an Example

Expand Down
3 changes: 3 additions & 0 deletions words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,6 @@ Lxkf
Tpeyg
getrandom
Curto
devcontainers
noninteractive
autoremove