Skip to content

Commit 7159e11

Browse files
Jaime Salas ZancadaJaime Salas Zancada
authored andcommitted
started configuration
1 parent d1e9208 commit 7159e11

File tree

12 files changed

+680
-0
lines changed

12 files changed

+680
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
2+
ARG VARIANT=16-bullseye
3+
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
4+
5+
# Install MongoDB command line tools - though mongo-database-tools not available on arm64
6+
ARG MONGO_TOOLS_VERSION=6.0
7+
RUN . /etc/os-release \
8+
&& curl -sSL "https://www.mongodb.org/static/pgp/server-${MONGO_TOOLS_VERSION}.asc" | gpg --dearmor > /usr/share/keyrings/mongodb-archive-keyring.gpg \
9+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian ${VERSION_CODENAME}/mongodb-org/${MONGO_TOOLS_VERSION} main" | tee /etc/apt/sources.list.d/mongodb-org-${MONGO_TOOLS_VERSION}.list \
10+
&& apt-get update && export DEBIAN_FRONTEND=noninteractive \
11+
&& apt-get install -y mongodb-mongosh \
12+
&& if [ "$(dpkg --print-architecture)" = "amd64" ]; then apt-get install -y mongodb-database-tools; fi \
13+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
14+
15+
# [Optional] Uncomment this section to install additional OS packages.
16+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
17+
# && apt-get -y install --no-install-recommends <your-package-list-here>
18+
19+
# [Optional] Uncomment if you want to install an additional version of node using nvm
20+
# ARG EXTRA_NODE_VERSION=10
21+
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
22+
23+
# [Optional] Uncomment if you want to install more global node modules
24+
# RUN su node -c "npm install -g <your-package-list-here>"
25+
26+
27+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/javascript-node-mongo
3+
// Update the VARIANT arg in docker-compose.yml to pick a Node.js version
4+
{
5+
"name": "Node.js & Mongo DB",
6+
"dockerComposeFile": "docker-compose.yml",
7+
"service": "app",
8+
"workspaceFolder": "/workspace",
9+
10+
// Configure tool-specific properties.
11+
"customizations": {
12+
// Configure properties specific to VS Code.
13+
"vscode": {
14+
// Add the IDs of extensions you want installed when the container is created.
15+
"extensions": [
16+
"dbaeumer.vscode-eslint",
17+
"mongodb.mongodb-vscode"
18+
]
19+
}
20+
},
21+
22+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
23+
"forwardPorts": [3000, 27017],
24+
25+
// Use 'postCreateCommand' to run commands after the container is created.
26+
// "postCreateCommand": "yarn install",
27+
28+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
29+
"remoteUser": "node",
30+
"features": {
31+
"docker-in-docker": "20.10",
32+
"docker-from-docker": "20.10"
33+
}
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
args:
9+
# Update 'VARIANT' to pick an LTS version of Node.js: 18, 16, 14.
10+
# Append -bullseye or -buster to pin to an OS version.
11+
# Use -bullseye variants on local arm64/Apple Silicon.
12+
VARIANT: 16-bullseye
13+
volumes:
14+
- ..:/workspace:cached
15+
16+
# Overrides default command so things don't shut down after the process ends.
17+
command: sleep infinity
18+
19+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
20+
network_mode: service:db
21+
# Uncomment the next line to use a non-root user for all processes.
22+
# user: node
23+
24+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
25+
# (Adding the "ports" property to this file will not forward from a Codespace.)
26+
27+
db:
28+
image: mongo:latest
29+
restart: unless-stopped
30+
volumes:
31+
- mongodb-data:/data/db
32+
# Uncomment to change startup options
33+
# environment:
34+
# MONGO_INITDB_ROOT_USERNAME: root
35+
# MONGO_INITDB_ROOT_PASSWORD: example
36+
# MONGO_INITDB_DATABASE: your-database-here
37+
38+
# Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally.
39+
# (Adding the "ports" property to this file will not forward from a Codespace.)
40+
41+
volumes:
42+
mongodb-data: null
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DATABASE_URL=mongodb://localhost:27017

0 commit comments

Comments
 (0)