Skip to content

Commit 1af96b3

Browse files
committed
feat: devcontainer with codespaces
1 parent 3e7a434 commit 1af96b3

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

.devcontainer/devcontainer.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Update the VARIANT arg in docker-compose.yml to pick a Node.js version
2+
{
3+
"name": "Node.js && Redis && MySQL",
4+
"dockerComposeFile": "../docker-compose.yml",
5+
"service": "app",
6+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7+
8+
// Configure tool-specific properties.
9+
"customizations": {
10+
// Configure properties specific to VS Code.
11+
"vscode": {
12+
// Add the IDs of extensions you want installed when the container is created.
13+
"extensions": [
14+
"mongodb.mongodb-vscode"
15+
]
16+
}
17+
},
18+
19+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
20+
"remoteUser": "node"
21+
}

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM mcr.microsoft.com/devcontainers/javascript-node:0-16-bullseye
2+
3+
# [Optional] Uncomment this section to install additional OS packages.
4+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
# && apt-get -y install --no-install-recommends <your-package-list-here>
6+
7+
# [Optional] Uncomment if you want to install an additional version of node using nvm
8+
# ARG EXTRA_NODE_VERSION=10
9+
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
10+
11+
# [Optional] Uncomment if you want to install more global node modules
12+
RUN su node -c "npm install -g pnpm"
13+
14+
15+

docker-compose.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1-
version: '3.6'
1+
version: '3.8'
22
services:
3+
app:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
volumes:
8+
- ../..:/workspaces:cached
9+
10+
# Overrides default command so things don't shut down after the process ends.
11+
command: sleep infinity
12+
13+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
14+
# network_mode: service:db
15+
networks:
16+
- cnpm
17+
18+
# Uncomment the next line to use a non-root user for all processes.
19+
# user: node
20+
21+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
22+
# (Adding the "ports" property to this file will not forward from a Codespace.)
23+
324
redis:
425
image: redis:6-alpine
526
# command: redis-server --appendonly yes --requirepass cnpm

0 commit comments

Comments
 (0)