Skip to content

Add dev container #6962

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 14 commits into from
Aug 23, 2024
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
10 changes: 10 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/devcontainers/rust:1-1-bookworm
LABEL org.opencontainers.image.authors="Christoph Knittel <[email protected]>"
LABEL org.opencontainers.image.description="Docker image for ReScript development."

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
opam \
musl-tools \
python-is-python3 \
&& rm -rf /var/lib/apt/lists/*
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "ReScript Compiler",
"build": {
"context": ".",
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1":{
"installDirectlyFromGitHubRelease": true,
"version": "latest"
},
"ghcr.io/devcontainers/features/node:1": {
"version":"20"
}
},
"customizations": {
"vscode": {
"extensions": [
"ocamllabs.ocaml-platform",
"chenglou92.rescript-vscode",
"biomejs.biome",
"rust-lang.rust-analyzer"
]
}
},
"postCreateCommand": ".devcontainer/postCreate.sh"
}
15 changes: 15 additions & 0 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# Install dev dependencies from OPAM
opam init -y --bare --disable-sandboxing
opam switch create 5.2.0 --packages ocaml-option-static
opam install . --deps-only -y

# For IDE support, install the OCaml language server
opam install ocaml-lsp-server -y

# Add OPAM environment setup to shell startup script
echo 'eval $(opam env)' >> ~/.zshrc
echo 'eval $(opam env)' >> ~/.bashrc

npm install --ignore-scripts
7 changes: 6 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"recommendations": ["biomejs.biome", "chenglou92.rescript-vscode"],
"recommendations": [
"biomejs.biome",
"chenglou92.rescript-vscode",
"ocamllabs.ocaml-platform",
"rust-lang.rust-analyzer"
],
"unwantedRecommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
- Fix incorrect format of function under unary operator. https://github.com/rescript-lang/rescript-compiler/pull/6953
- Fix incorrect incorrect printing of module binding with signature. https://github.com/rescript-lang/rescript-compiler/pull/6963

#### :house: Internal

- Add dev container. https://github.com/rescript-lang/rescript-compiler/pull/6962

# 12.0.0-alpha.1

#### :rocket: New Feature
Expand Down
16 changes: 14 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ git clone --depth 1 https://github.com/rescript-lang/rescript-compiler.git

This will only consume less than 50MB.

## Install OCaml compiler + dependencies
## Installation

### A. Manual installation

#### Install OCaml compiler + dependencies

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

Expand All @@ -51,10 +55,18 @@ opam install . --deps-only
opam install ocaml-lsp-server
```

## npm install
#### npm install

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

### B. Devcontainer

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.

Run the `Dev Containers: Rebuild and Reopen in Container` action to get started.

You can also open this dev container with [GitHub Codespaces](https://github.com/features/codespaces/).

## Building the Compiler

The compiler binaries themselves can be built directly with dune as follows:
Expand Down
14 changes: 0 additions & 14 deletions docker/Dockerfile

This file was deleted.