Skip to content

Commit

Permalink
feat: add devcontainer support
Browse files Browse the repository at this point in the history
  • Loading branch information
brakmic committed Dec 27, 2024
1 parent c1557cb commit 6ddc12a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Passport-KC-OAuth-OIDC DevContainer",
"image": "brakmic/jsdev-docker:latest",
"workspaceFolder": "/workspace",
"workspaceMount": "source=${localWorkspaceFolder},target=/host_workspace,type=bind,consistency=cached",
"customizations": {
"vscode": {
"settings": {
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true
}
}
}
},
"mounts": [
"source=${localWorkspaceFolder}/.devcontainer/setup-workspace.mjs,target=/workspace/.devcontainer/setup-workspace.mjs,type=bind",
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],
"forwardPorts": [8080],
"postCreateCommand": "node /workspace/.devcontainer/setup-workspace.mjs && ln -sf /workspace/dev.code-workspace /home/jsdev/.vscode-server/dev.code-workspace",
"remoteUser": "jsdev",
"containerEnv": {
"HOST_WORKSPACE": "${localWorkspaceFolder}"
}
}
30 changes: 30 additions & 0 deletions .devcontainer/setup-workspace.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import fs from "fs";
import path from "path";

// Workspace file path
const workspaceFilePath = "/workspace/dev.code-workspace";

// Ensure the directory for the workspace file exists
const dirPath = path.dirname(workspaceFilePath);
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
}

// Define the workspace configuration
const workspaceConfig = {
folders: [
{
name: "DevContainer Workspace",
path: "/workspace"
},
{
name: "Host Workspace",
path: "/host_workspace"
}
],
settings: {}
};

// Write the workspace file
fs.writeFileSync(workspaceFilePath, JSON.stringify(workspaceConfig, null, 2));
console.log(`Workspace file created: ${workspaceFilePath}`);

0 comments on commit 6ddc12a

Please sign in to comment.