diff --git a/containers/gleam-erlang/.devcontainer/Dockerfile b/containers/gleam-erlang/.devcontainer/Dockerfile new file mode 100644 index 0000000000..1eef301f54 --- /dev/null +++ b/containers/gleam-erlang/.devcontainer/Dockerfile @@ -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 + +# [Optional] Uncomment this line to install additional package. +# RUN gleam add ... \ No newline at end of file diff --git a/containers/gleam-erlang/.devcontainer/devcontainer.json b/containers/gleam-erlang/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..2843011941 --- /dev/null +++ b/containers/gleam-erlang/.devcontainer/devcontainer.json @@ -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" +} diff --git a/containers/gleam-erlang/.npmignore b/containers/gleam-erlang/.npmignore new file mode 100644 index 0000000000..e4ebfc71a5 --- /dev/null +++ b/containers/gleam-erlang/.npmignore @@ -0,0 +1,5 @@ +README.md +test-project +definition-manifest.json +.vscode +.npmignore diff --git a/containers/gleam-erlang/README.md b/containers/gleam-erlang/README.md new file mode 100644 index 0000000000..30b7d4a9ae --- /dev/null +++ b/containers/gleam-erlang/README.md @@ -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 F1 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 F1 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 F1, 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). diff --git a/containers/gleam-erlang/test-project/.gitignore b/containers/gleam-erlang/test-project/.gitignore new file mode 100644 index 0000000000..170cca9816 --- /dev/null +++ b/containers/gleam-erlang/test-project/.gitignore @@ -0,0 +1,4 @@ +*.beam +*.ez +build +erl_crash.dump diff --git a/containers/gleam-erlang/test-project/README.md b/containers/gleam-erlang/test-project/README.md new file mode 100644 index 0000000000..9aaade16ec --- /dev/null +++ b/containers/gleam-erlang/test-project/README.md @@ -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 +``` diff --git a/containers/gleam-erlang/test-project/gleam.toml b/containers/gleam-erlang/test-project/gleam.toml new file mode 100644 index 0000000000..dfc838be7c --- /dev/null +++ b/containers/gleam-erlang/test-project/gleam.toml @@ -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" diff --git a/containers/gleam-erlang/test-project/manifest.toml b/containers/gleam-erlang/test-project/manifest.toml new file mode 100644 index 0000000000..2700b864b9 --- /dev/null +++ b/containers/gleam-erlang/test-project/manifest.toml @@ -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" diff --git a/containers/gleam-erlang/test-project/src/test_project.gleam b/containers/gleam-erlang/test-project/src/test_project.gleam new file mode 100644 index 0000000000..ccd1763b92 --- /dev/null +++ b/containers/gleam-erlang/test-project/src/test_project.gleam @@ -0,0 +1,5 @@ +import gleam/io + +pub fn main() { + io.println("Hello from test_project!") +} diff --git a/containers/gleam-erlang/test-project/test/test_project_test.gleam b/containers/gleam-erlang/test-project/test/test_project_test.gleam new file mode 100644 index 0000000000..3831e7a97a --- /dev/null +++ b/containers/gleam-erlang/test-project/test/test_project_test.gleam @@ -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) +}