Skip to content

Commit 6ce68e8

Browse files
committed
add dev container
1 parent e5ae74c commit 6ce68e8

5 files changed

Lines changed: 124 additions & 0 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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.195.0/containers/javascript-node
3+
{
4+
"name": "coderdojo-site-react",
5+
"dockerComposeFile": [
6+
"../docker-compose.yml",
7+
"docker-compose.extend.yml"
8+
],
9+
"service": "dev",
10+
// "build": {
11+
// "dockerfile": "Dockerfile",
12+
// // Update 'VARIANT' to pick a Node version: 16, 14, 12.
13+
// // Append -bullseye or -buster to pin to an OS version.
14+
// // Use -bullseye variants on local arm64/Apple Silicon.
15+
// "args": {
16+
// "VARIANT": "18-bullseye"
17+
// }
18+
// },
19+
// Configure tool-specific properties.
20+
"customizations": {
21+
// Configure properties specific to VS Code.
22+
"vscode": {
23+
// Set *default* container specific settings.json values on container create.
24+
// see https://stackoverflow.com/a/69085491/430721 - prettier conflicts
25+
"settings": {
26+
"editor.defaultFormatter": "esbenp.prettier-vscode",
27+
"editor.formatOnSave": false,
28+
"editor.codeActionsOnSave": {
29+
"source.fixAll.eslint": "explicit",
30+
"source.fixAll.stylelint": "explicit"
31+
},
32+
"git.postCommitCommand": "push",
33+
"css.validate": false,
34+
"scss.validate": false,
35+
"stylelint.validate": [
36+
"css",
37+
"scss"
38+
],
39+
"typescript.preferences.includePackageJsonAutoImports": "on"
40+
},
41+
// Add the IDs of extensions you want installed when the container is created.
42+
"extensions": [
43+
"dbaeumer.vscode-eslint",
44+
"esbenp.prettier-vscode",
45+
"GitHub.copilot",
46+
"GitHub.copilot-chat",
47+
"stylelint.vscode-stylelint",
48+
"streetsidesoftware.code-spell-checker"
49+
]
50+
}
51+
},
52+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
53+
// "forwardPorts": [3000],
54+
// Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
55+
// "portsAttributes": {
56+
// "3000": {
57+
// "label": "Hello Remote World",
58+
// "onAutoForward": "notify"
59+
// }
60+
// },
61+
// Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
62+
// "otherPortsAttributes": {
63+
// "onAutoForward": "silent"
64+
// },
65+
// Use 'postCreateCommand' to run commands after the container is created.
66+
"postCreateCommand": "./scripts/post-install.sh",
67+
//https://www.kenmuse.com/blog/avoiding-dubious-ownership-in-dev-containers/
68+
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
69+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
70+
"remoteUser": "node",
71+
"workspaceFolder": "/workspace",
72+
"remoteEnv": {
73+
"PATH": "${containerEnv:PATH}:/workspace/node_modules/.bin:/workspace/scripts",
74+
"EDITOR": "nano",
75+
"AWS_PROFILE": "rocsys-int",
76+
"DATABASE_URL": "postgres://root:root@pg_container:5432/rocsyscloud"
77+
}
78+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3'
2+
services:
3+
dev:
4+
volumes:
5+
# Mounts the project folder to '/workspace'. While this file is in .devcontainer,
6+
# mounts are relative to the first file in the list, which is a level up.
7+
- .:/workspace:cached
8+
9+
# [Optional] Required for ptrace-based debuggers like C++, Go, and Rust
10+
cap_add:
11+
- SYS_PTRACE
12+
security_opt:
13+
- seccomp:unconfined
14+
15+
# Overrides default command so things don't shut down after the process ends.
16+
command: /bin/sh -c "while sleep 1000; do :; done"

Dockerfile-dev

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Stage: devserver
2+
FROM node:22.19.0-trixie AS devserver
3+
4+
RUN apt-get update && \
5+
apt-get install -y \
6+
less \
7+
nano \
8+
sysstat \
9+
uuid-runtime \
10+
jq
11+
RUN mkdir -p \
12+
/workspace/klimkalender-new/node_modules && \
13+
chown node:node \
14+
/workspace/klimkalender-new/node_modules
15+
16+
USER node
17+
RUN touch /home/node/.bashrc && echo "source /usr/share/bash-completion/completions/git" >> /home/node/.bashrc
18+
ENV SHELL /bin/bash

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: "3.8"
2+
services:
3+
dev:
4+
build:
5+
context: ./
6+
target: devserver
7+
dockerfile: Dockerfile-dev
8+
tty: true
9+
stdin_open: true

scripts/post-install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# add init script
2+
npm install --legacy-peer-deps
3+
echo "welome!"

0 commit comments

Comments
 (0)