Skip to content

Commit

Permalink
Add Dev Container (#8)
Browse files Browse the repository at this point in the history
This PR adds a [Dev Container](https://containers.dev) to the project
for easier project setup and development.

There are a number of IDEs and tools that support Dev Containers, but
the following testing instructions will assume VS Code (for good or for
ill).


0. Install Docker Desktop, VS Code, and the VS Code Dev Containers
extension
1. Switch to this branch: `git switch add-devcontainer`
2. Open the project in VS Code
3. Open the command palette (`cmd-shift-p` on macOS) and serach for "Dev
Containers: Reopen in Container"
4. Wait for the Dev Container to pull and build the development image
5. Open a new VS Code terminal tab (`cmd-j` on macOS to show the panel)
6. Run formatting: `mix format --check-formatted`
7. Run tests: `mix test`
8. Generate docs: `mix docs`

🥳
  • Loading branch information
jgarber623-cargosense authored Jun 10, 2024
2 parents c509e2d + 9f59cff commit 364c811
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "compare_chain",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "elixir:1.16-otp-26-slim",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installOhMyZsh": false,
"installOhMyZshConfig": false
},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/github-cli:1": {}
},

// 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": ".devcontainer/setup.sh",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"EditorConfig.EditorConfig",
"JakeBecker.elixir-ls"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
8 changes: 8 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -euo pipefail
IFS=$'\n\t'
set -vx

mix local.hex --force
mix deps.get
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ compare_chain-*.tar

# Temporary files, for example, from tests.
/tmp/

# Ignore files generated by Elixir Language Server IDE plugin.
.elixir_ls

0 comments on commit 364c811

Please sign in to comment.