Skip to content

Instantly share code, notes, and snippets.

@PercyODI
Created November 30, 2021 02:47
Show Gist options
  • Save PercyODI/bd6e575b967ba2c4e7f343b6b196e717 to your computer and use it in GitHub Desktop.
Save PercyODI/bd6e575b967ba2c4e7f343b6b196e717 to your computer and use it in GitHub Desktop.
Basic Setup for VS Code Remote Development of Elixir from WSL2 and Podman
// 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.205.2/containers/elixir
{
"name": "Elixir (Community)",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Elixir Version: 1.9, 1.10, 1.10.4, ...
"VARIANT": "latest"
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"jakebecker.elixir-ls"
],
// 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": "mix deps.get"
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z",
"workspaceFolder": "/workspace",
"runArgs": [
"--userns=keep-id"
],
"containerUser": "vscode"
}
# Update the VARIANT arg in docker-compose.yml to pick an Elixir version: 1.9, 1.10, 1.10.4
ARG VARIANT=latest
FROM docker.io/elixir:${VARIANT}
# This Dockerfile adds a non-root user with sudo access. Update the “remoteUser” property in
# devcontainer.json to use it. More info: https://aka.ms/vscode-remote/containers/non-root-user.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Options for common package install script
ARG INSTALL_ZSH="true"
ARG UPGRADE_PACKAGES="true"
ARG COMMON_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/v0.205.2/script-library/common-debian.sh"
ARG COMMON_SCRIPT_SHA="84cb2f8be279acaa04136ad00e9226c7e1a63edd42ceb3c0f5feb627f1252ccc"
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
RUN apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends curl ca-certificates 2>&1
RUN curl -sSL ${COMMON_SCRIPT_SOURCE} -o /tmp/common-setup.sh \
&& ([ "${COMMON_SCRIPT_SHA}" = "dev-mode" ] || (echo "${COMMON_SCRIPT_SHA} */tmp/common-setup.sh" | sha256sum -c -)) \
&& chmod +x /tmp/common-setup.sh
RUN /tmp/common-setup.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}"
#
# Install dependencies
RUN apt-get install -y build-essential \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* /tmp/common-setup.sh /tmp/node-setup.sh
RUN su ${USERNAME} -c "mix local.hex --force \
&& mix local.rebar --force"
# [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 mix ...
IO.puts("Hello world from Elixir")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment