Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add devcontainer for working on windows
- Loading branch information
Showing
3 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
|
||
FROM node:12 | ||
|
||
# Avoid warnings by switching to noninteractive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# The node image includes a non-root user with sudo access. Use the | ||
# "remoteUser" property in devcontainer.json to use it. On Linux, update | ||
# these values to ensure the container user's UID/GID matches your local values. | ||
# See https://aka.ms/vscode-remote/containers/non-root-user for details. | ||
ARG USERNAME=node | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
# Configure apt and install packages | ||
RUN apt-get update \ | ||
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ | ||
# | ||
# Verify git and needed tools are installed | ||
&& apt-get -y install git iproute2 procps \ | ||
# | ||
# Remove outdated yarn from /opt and install via package | ||
# so it can be easily updated via apt-get upgrade yarn | ||
&& rm -rf /opt/yarn-* \ | ||
&& rm -f /usr/local/bin/yarn \ | ||
&& rm -f /usr/local/bin/yarnpkg \ | ||
&& apt-get install -y curl apt-transport-https lsb-release \ | ||
&& curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \ | ||
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ | ||
&& apt-get update \ | ||
&& apt-get -y install --no-install-recommends yarn tmux locales \ | ||
# | ||
# Install eslint globally | ||
&& npm install -g eslint \ | ||
# | ||
# [Optional] Update a non-root user to UID/GID if needed. | ||
&& if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \ | ||
groupmod --gid $USER_GID $USERNAME \ | ||
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \ | ||
&& chown -R $USER_UID:$USER_GID /home/$USERNAME; \ | ||
fi \ | ||
# [Optional] Add add sudo support for non-root user | ||
&& apt-get install -y sudo \ | ||
&& echo node ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME \ | ||
# | ||
# Clean up | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl https://raw.githubusercontent.com/brianc/dotfiles/master/.tmux.conf > ~/.tmux.conf | ||
|
||
# install nvm | ||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash | ||
|
||
# Set the locale | ||
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
# Switch back to dialog for any ad-hoc use of apt-get | ||
ENV DEBIAN_FRONTEND=dialog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml. | ||
{ | ||
"name": "Node.js 12 & Postgres", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "web", | ||
"workspaceFolder": "/workspace", | ||
|
||
// Use 'settings' to set *default* container specific settings.json values on container create. | ||
// You can edit these settings after create using File > Preferences > Settings > Remote. | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
|
||
// Uncomment the next line if you want start specific services in your Docker Compose config. | ||
// "runServices": [], | ||
|
||
// Uncomment the line below if you want to keep your containers running after VS Code shuts down. | ||
// "shutdownAction": "none", | ||
|
||
// Uncomment the next line to run commands after the container is created. | ||
// "postCreateCommand": "npm install", | ||
|
||
// Uncomment the next line to have VS Code connect as an existing non-root user in the container. See | ||
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist. | ||
// "remoteUser": "node", | ||
|
||
// Add the IDs of extensions you want installed when the container is created in the array below. | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
|
||
version: '3' | ||
services: | ||
web: | ||
# Uncomment the next line to use a non-root user for all processes. You can also | ||
# simply use the "remoteUser" property in devcontainer.json if you just want VS Code | ||
# and its sub-processes (terminals, tasks, debugging) to execute as the user. On Linux, | ||
# you may need to update USER_UID and USER_GID in .devcontainer/Dockerfile to match your | ||
# user if not 1000. See https://aka.ms/vscode-remote/containers/non-root for details. | ||
# user: node | ||
|
||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
|
||
volumes: | ||
- ..:/workspace:cached | ||
|
||
environment: | ||
PGPASSWORD: pass | ||
PGUSER: user | ||
PGDATABASE: data | ||
PGHOST: db | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: sleep infinity | ||
|
||
links: | ||
- db | ||
|
||
db: | ||
image: postgres | ||
restart: unless-stopped | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
POSTGRES_PASSWORD: pass | ||
POSTGRES_USER: user | ||
POSTGRES_DB: data | ||
|