Skip to content

Commit

Permalink
Adding devcontainer for remote-extensions and codespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreiding committed Dec 15, 2021
1 parent 8fea200 commit cc02273
Show file tree
Hide file tree
Showing 9 changed files with 1,104 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Note: You can use any Debian/Ubuntu based image you want.
FROM mcr.microsoft.com/vscode/devcontainers/base:bullseye

# [Option] Install zsh
ARG INSTALL_ZSH="true"
# [Option] Upgrade OS packages to their latest versions
ARG UPGRADE_PACKAGES="false"
# [Option] Enable non-root Docker access in container
ARG ENABLE_NONROOT_DOCKER="true"
# [Option] Use the OSS Moby CLI instead of the licensed Docker CLI
ARG USE_MOBY="true"

# Enable new "BUILDKIT" mode for Docker CLI
ENV DOCKER_BUILDKIT=1

# Install needed packages and setup non-root user. Use a separate RUN statement to add your
# own dependencies. A user of "automatic" attempts to reuse an user ID if one already exists.
ARG USERNAME=automatic
ARG USER_UID=1000
ARG USER_GID=$USER_UID
COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
RUN apt-get update \
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "${INSTALL_ZSH}" "true" \
# Use Docker script from script library to set things up
&& /bin/bash /tmp/library-scripts/docker-debian.sh "${ENABLE_NONROOT_DOCKER}" "/var/run/docker-host.sock" "/var/run/docker.sock" "${USERNAME}"

ENV NVM_DIR=/usr/local/share/nvm
ENV PATH=${NVM_DIR}/current/bin:${PATH}
ARG NODE_MODULES="eslint typescript tslint-to-eslint-config "
COPY library-scripts/meta.env /usr/local/etc/vscode-dev-containers

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
&& apt-get purge -y imagemagick imagemagick-6-common \
# Install yarn, nvm
&& rm -rf /opt/yarn-* /usr/local/bin/yarn /usr/local/bin/yarnpkg \
&& bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "lts" "${USERNAME}" \
&& apt-get -y install --no-install-recommends python-is-python3 \
&& if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
&& usermod -a -G npm ${USERNAME} \
&& su ${USERNAME} -c "umask 0002 && npm install -g ${NODE_MODULES}" \
&& npm cache clean --force > /dev/null 2>&1

RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/

# Setting the ENTRYPOINT to docker-init.sh will configure non-root access
# to the Docker socket. The script will also execute CMD as needed.
ENTRYPOINT [ "/usr/local/share/docker-init.sh" ]
CMD [ "sleep", "infinity" ]

# [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>
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile.temporalite
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:1.17 AS builder

RUN go install github.com/DataDog/temporalite/cmd/temporalite@latest
RUN go install -v github.com/temporalio/tctl/cmd@latest

RUN mv /go/bin/cmd /go/bin/tctl

EXPOSE 7233
ENTRYPOINT ["/go/bin/temporalite", "start", "--ephemeral", "-n", "default", "--ip" , "0.0.0.0"]
50 changes: 50 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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.209.5/containers/javascript-node-postgres
// Update the VARIANT arg in docker-compose.yml to pick a Node.js version
{
"name": "Samples Typescript",
"dockerComposeFile": "docker-compose.yml",
"service": "samples",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose",
// Set *default* container specific settings.json values on container create.
"settings": {
"sqltools.connections": [
{
"name": "temporal",
"driver": "PostgreSQL",
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"database": "temporal",
"username": "temporal",
"password": "temporal"
},
{
"name": "visibility",
"driver": "PostgreSQL",
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"database": "temporal_visibility",
"username": "temporal",
"password": "temporal"
}
],
"#terminal.integrated.defaultProfile.linux#": "bash",
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-azuretools.vscode-docker",
"dbaeumer.vscode-eslint",
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8080,
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"updateRemoteUserUID": true,
}
57 changes: 57 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: '3.8'

services:
samples:
container_name: samples_dev
image: samples:test
build:
context: .
dockerfile: Dockerfile
args:
USERNAME: vscode
INSTALL_ZSH: false
UPGRADE_PACKAGES: true

volumes:
# Forwards the local Docker socket to the container.
- /var/run/docker.sock:/var/run/docker-host.sock
# Update this to wherever you want VS Code to mount the folder of your project
- ..:/workspace:cached

# Overrides default command so things don't shut down after the process ends.
entrypoint: /usr/local/share/docker-init.sh
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:temporalite
depends_on:
- temporalite

# Uncomment the next line to use a non-root user for all processes.
user: vscode

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

temporalite:
build:
context: .
dockerfile: Dockerfile.temporalite
image: temporalite:test
container_name: samples_temporalite
ports:
- 7233:7233
environment:
TEMPORAL_CLI_ADDRESS: localhost:7233

web:
image: temporaliotest/ui:latest
container_name: samples_web
depends_on:
- temporalite
environment:
TEMPORAL_ADDRESS: "localhost:7233"

network_mode: service:temporalite
restart: unless-stopped

Loading

0 comments on commit cc02273

Please sign in to comment.