Skip to content

Commit

Permalink
feat(dev): add devcontainers support
Browse files Browse the repository at this point in the history
Automate the setup of development environment via devcontainers.
  • Loading branch information
uwla committed Dec 31, 2023
1 parent 0e8d29b commit 67520c0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM debian

ENV DEBIAN_FRONTEND=noninteractive

# install some development packages
RUN apt-get update -y && \
apt-get install -y apt-utils binutils curl git gnupg less python3 rpm

# install yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
apt update -y && \
apt install -y --no-install-recommends yarn

# workdir
RUN mkdir /app && chown 1000:1000 /app
WORKDIR /app

# create non-root user and switch to it from here on
RUN useradd -m -u 1000 -U -s /bin/bash debian
USER debian

# install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# install node 16.20.2
RUN bash -c '. ~/.nvm/nvm.sh && nvm install 16.20.2'

# add node to PATH
ENV PATH=/home/debian/.nvm/versions/node/v16.20.2/bin:$PATH

26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": ".",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "Dockerfile"
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

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

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {}

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}

0 comments on commit 67520c0

Please sign in to comment.