Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Dev container for gleam lang development #1220

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions containers/gleam-erlang/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM mcr.microsoft.com/vscode/devcontainers/base:debian

ARG GLEAM_VERSION="v0.18.2"

RUN apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends erlang 2>&1 \
&& curl -sSL https://github.com/gleam-lang/gleam/releases/download/${GLEAM_VERSION}/gleam-${GLEAM_VERSION}-linux-amd64.tar.gz -o /tmp/gleam.tar.az \
&& tar -xzvf /tmp/gleam.tar.az -C /usr/local/bin \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* /tmp/gleam.tar.az

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update \
# && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install additional package.
# RUN gleam add ...
27 changes: 27 additions & 0 deletions containers/gleam-erlang/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.224.2/containers/gleam-erlang
{
"name": "Gleam with erlang (Community)",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Elaem Version: v0.18.2, v0.17.0, ...
"GLEAM_VERSION": "v0.18.2"
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"Gleam.gleam",
"tamasfe.even-better-toml"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gleam -V"

// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
5 changes: 5 additions & 0 deletions containers/gleam-erlang/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
README.md
test-project
definition-manifest.json
.vscode
.npmignore
53 changes: 53 additions & 0 deletions containers/gleam-erlang/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Gleam with Erlang Runtime (Community)

## Summary

_Develop Gleam based applications. Includes everything you need to get up and running._

| Metadata | Value |
| --------------------------- | --------------------- |
| _Contributors_ | [mrchypark](https://github.com/mrchypark)|
| _Category_ | Community, Languages |
| _Definition type_ | Dockerfile |
| _Works in Codespaces_ | Yes |
| _Container host OS support_ | Linux, macOS, Windows |
| _Languages, platforms_ | Gleam |

## Using this definition

While this definition should work unmodified, you can select the version of Gleam compiler the container uses by updating the `GLEAM_VERSION` arg in the included `devcontainer.json`.

```json
"args": { "GLEAM_VERSION": "v0.18.2" }
```

### Adding the definition to your folder

1. If this is your first time using a development container, please see getting started information on [setting up](https://aka.ms/vscode-remote/containers/getting-started) Remote-Containers or [creating a codespace](https://aka.ms/ghcs-open-codespace) using GitHub Codespaces.

2. Start VS Code and open your project folder or connect to a codespace.

3. Press <kbd>F1</kbd> select and **Add Development Container Configuration Files...** command for **Remote-Containers** or **Codespaces**.

> **Note:** If needed, you can drag-and-drop the `.devcontainer` folder from this sub-folder in a locally cloned copy of this repository into the VS Code file explorer instead of using the command.

4. Select this definition. You may also need to select **Show All Definitions...** for it to appear.

5. Finally, press <kbd>F1</kbd> and run **Remote-Containers: Reopen Folder in Container** or **Codespaces: Rebuild Container** to start using the definition.

## Testing the definition

This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:

1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
2. Clone this repository.
3. Start VS Code, press <kbd>F1</kbd>, and select **Remote-Containers: Open Folder in Container...**
4. Select the `containers/gleam-erlang` folder.
5. After the folder has opened in the container, open a terminal in the `test-project` folder (`cd test-project/`) and run the following command: `gleam run test_project`
6. You should see `Hello from test_project!` message after compile and run.

## License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See [LICENSE](https://github.com/microsoft/vscode-dev-containers/blob/main/LICENSE).
4 changes: 4 additions & 0 deletions containers/gleam-erlang/test-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.beam
*.ez
build
erl_crash.dump
19 changes: 19 additions & 0 deletions containers/gleam-erlang/test-project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# test_project

A Gleam project

## Quick start

```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```

## Installation

If available on Hex this package can be added to your Gleam project.

```sh
gleam add test_project
```
16 changes: 16 additions & 0 deletions containers/gleam-erlang/test-project/gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name = "test_project"
version = "0.1.0"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
#
# licences = ["Apache-2.0"]
# description = "A Gleam library..."
# repository = { type = "github", user = "username", repo = "project" }
# links = [{ title = "Website", href = "https://gleam.run" }]

[dependencies]
gleam_stdlib = "~> 0.18"

[dev-dependencies]
gleeunit = "~> 0.5"
11 changes: 11 additions & 0 deletions containers/gleam-erlang/test-project/manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was generated by Gleam
# You typically do not need to edit this file

packages = [
{ name = "gleam_stdlib", version = "0.18.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "763ECD87D54D08755EE4C8551720D122FDCA47F61D1CA8AF23B19A90395A7468" },
{ name = "gleeunit", version = "0.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7FA7477D930178C1E59519DBDB5E086BE3A6B65F015B67DA94D30A323062154" },
]

[requirements]
gleam_stdlib = "~> 0.18"
gleeunit = "~> 0.5"
5 changes: 5 additions & 0 deletions containers/gleam-erlang/test-project/src/test_project.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import gleam/io

pub fn main() {
io.println("Hello from test_project!")
}
12 changes: 12 additions & 0 deletions containers/gleam-erlang/test-project/test/test_project_test.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import gleeunit
import gleeunit/should

pub fn main() {
gleeunit.main()
}

// gleeunit test functions end in `_test`
pub fn hello_world_test() {
1
|> should.equal(1)
}