Skip to content

Commit 897cc22

Browse files
nojafrootcknitt
authored
Add dev container (rescript-lang#6962)
* Add devcontainer json * Add GitHub CLI feature * Try and create user instead of root. * Default to bash * Simplify Dockerfile and devcontainer * Move opam install to postCreate * Add ocamllabs.ocaml-platform extension * Add extensions * Remove trailing comma * Add changelog entry * Add opam env to bashrc * Update contributing * Update CONTRIBUTING.md Co-authored-by: Christoph Knittel <[email protected]> * Update .devcontainer/postCreate.sh Co-authored-by: Christoph Knittel <[email protected]> --------- Co-authored-by: root <root@nojaf-desktop> Co-authored-by: Christoph Knittel <[email protected]>
1 parent 27e3dce commit 897cc22

File tree

7 files changed

+76
-17
lines changed

7 files changed

+76
-17
lines changed

.devcontainer/Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM mcr.microsoft.com/devcontainers/rust:1-1-bookworm
2+
LABEL org.opencontainers.image.authors="Christoph Knittel <[email protected]>"
3+
LABEL org.opencontainers.image.description="Docker image for ReScript development."
4+
5+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
6+
&& apt-get -y install --no-install-recommends \
7+
opam \
8+
musl-tools \
9+
python-is-python3 \
10+
&& rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "ReScript Compiler",
3+
"build": {
4+
"context": ".",
5+
"dockerfile": "Dockerfile"
6+
},
7+
"features": {
8+
"ghcr.io/devcontainers/features/github-cli:1":{
9+
"installDirectlyFromGitHubRelease": true,
10+
"version": "latest"
11+
},
12+
"ghcr.io/devcontainers/features/node:1": {
13+
"version":"20"
14+
}
15+
},
16+
"customizations": {
17+
"vscode": {
18+
"extensions": [
19+
"ocamllabs.ocaml-platform",
20+
"chenglou92.rescript-vscode",
21+
"biomejs.biome",
22+
"rust-lang.rust-analyzer"
23+
]
24+
}
25+
},
26+
"postCreateCommand": ".devcontainer/postCreate.sh"
27+
}

.devcontainer/postCreate.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# Install dev dependencies from OPAM
4+
opam init -y --bare --disable-sandboxing
5+
opam switch create 5.2.0 --packages ocaml-option-static
6+
opam install . --deps-only -y
7+
8+
# For IDE support, install the OCaml language server
9+
opam install ocaml-lsp-server -y
10+
11+
# Add OPAM environment setup to shell startup script
12+
echo 'eval $(opam env)' >> ~/.zshrc
13+
echo 'eval $(opam env)' >> ~/.bashrc
14+
15+
npm install --ignore-scripts

.vscode/extensions.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
2-
"recommendations": ["biomejs.biome", "chenglou92.rescript-vscode"],
2+
"recommendations": [
3+
"biomejs.biome",
4+
"chenglou92.rescript-vscode",
5+
"ocamllabs.ocaml-platform",
6+
"rust-lang.rust-analyzer"
7+
],
38
"unwantedRecommendations": [
49
"dbaeumer.vscode-eslint",
510
"esbenp.prettier-vscode"

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
- Fix incorrect format of function under unary operator. https://github.com/rescript-lang/rescript-compiler/pull/6953
3131
- Fix incorrect incorrect printing of module binding with signature. https://github.com/rescript-lang/rescript-compiler/pull/6963
3232

33+
#### :house: Internal
34+
35+
- Add dev container. https://github.com/rescript-lang/rescript-compiler/pull/6962
36+
3337
# 12.0.0-alpha.1
3438

3539
#### :rocket: New Feature

CONTRIBUTING.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ git clone --depth 1 https://github.com/rescript-lang/rescript-compiler.git
3232

3333
This will only consume less than 50MB.
3434

35-
## Install OCaml compiler + dependencies
35+
## Installation
36+
37+
### A. Manual installation
38+
39+
#### Install OCaml compiler + dependencies
3640

3741
The ReScript compiler compiles with any recent OCaml compiler. We are using `dune` as a build system for easy workflows and proper IDE support.
3842

@@ -51,10 +55,18 @@ opam install . --deps-only
5155
opam install ocaml-lsp-server
5256
```
5357

54-
## npm install
58+
#### npm install
5559

5660
Run `npm install --ignore-scripts`. This will install the npm dependencies required for the build scripts.
5761

62+
### B. Devcontainer
63+
64+
As an alternative to the manual installation, the repository provides a [development container](https://containers.dev/) definition that can be used with [VS Code's Remote Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). Use this to get a stable development environment without having to install anything locally other than VS Code and Docker.
65+
66+
Run the `Dev Containers: Rebuild and Reopen in Container` action to get started.
67+
68+
You can also open this dev container with [GitHub Codespaces](https://github.com/features/codespaces/).
69+
5870
## Building the Compiler
5971

6072
The compiler binaries themselves can be built directly with dune as follows:

docker/Dockerfile

-14
This file was deleted.

0 commit comments

Comments
 (0)