From f7198e3734965f293fe944b8211a5d9c4235d5d7 Mon Sep 17 00:00:00 2001 From: Jean Khawand <22157081+jeankhawand@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:31:33 +0200 Subject: [PATCH] feat: Initial Dev Containers setup (no-changelog) (#8951) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ --- .devcontainer/Dockerfile | 7 +++++++ .devcontainer/devcontainer.json | 19 +++++++++++++++++++ .devcontainer/docker-compose.yml | 23 +++++++++++++++++++++++ .npmrc | 3 +++ CONTRIBUTING.md | 5 +++++ n8n.code-workspace | 7 +++++++ 6 files changed, 64 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 n8n.code-workspace diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..cffda42f08 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,7 @@ +FROM n8nio/base:20 + +RUN apk add --no-cache --update openssh sudo shadow bash +RUN echo node ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/node && chmod 0440 /etc/sudoers.d/node +RUN mkdir /workspaces && chown node:node /workspaces +USER node +RUN mkdir -p ~/.pnpm-store && pnpm config set store-dir ~/.pnpm-store --global diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..c81220d1b4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +{ + "name": "n8n", + "dockerComposeFile": "docker-compose.yml", + "service": "n8n", + "workspaceFolder": "/workspaces", + "mounts": [ + "type=bind,source=${localWorkspaceFolder},target=/workspaces,consistency=cached", + "type=bind,source=${localEnv:HOME}/.ssh,target=/home/node/.ssh,consistency=cached", + "type=bind,source=${localEnv:HOME}/.n8n,target=/home/node/.n8n,consistency=cached" + ], + "forwardPorts": [8080, 5678], + "postCreateCommand": "corepack prepare --activate && pnpm install ", + "postAttachCommand": "pnpm build", + "customizations": { + "codespaces": { + "openFiles": ["CONTRIBUTING.md"] + } + } +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000000..7ecead94b6 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,23 @@ +volumes: + postgres-data: + +services: + postgres: + image: postgres:16-alpine + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + - POSTGRES_DB=n8n + - POSTGRES_PASSWORD=password + + n8n: + build: + context: . + dockerfile: Dockerfile + volumes: + - ..:/workspaces:cached + command: sleep infinity + environment: + DB_TYPE: postgresdb + DB_POSTGRESDB_PASSWORD: password diff --git a/.npmrc b/.npmrc index 688ccc8857..42d2964a04 100644 --- a/.npmrc +++ b/.npmrc @@ -9,3 +9,6 @@ hoist = true shamefully-hoist = true hoist-workspace-packages = false loglevel = warn +package-manager-strict=false +# https://github.com/pnpm/pnpm/issues/7024 +package-import-method=clone-or-copy diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d60df9eb96..6602d748b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,6 +9,7 @@ Great that you are here and you want to contribute to n8n - [Code of conduct](#code-of-conduct) - [Directory structure](#directory-structure) - [Development setup](#development-setup) + - [Dev Container](#dev-container) - [Requirements](#requirements) - [Node.js](#nodejs) - [pnpm](#pnpm) @@ -60,6 +61,10 @@ The most important directories: If you want to change or extend n8n you have to make sure that all the needed dependencies are installed and the packages get linked correctly. Here's a short guide on how that can be done: +### Dev Container + +If you already have VS Code and Docker installed, you can click [here](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/n8n-io/n8n) to get started. Clicking these links will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use. + ### Requirements #### Node.js diff --git a/n8n.code-workspace b/n8n.code-workspace new file mode 100644 index 0000000000..9d32d7aa04 --- /dev/null +++ b/n8n.code-workspace @@ -0,0 +1,7 @@ +{ + "folders": [ + { + "path": ".", + }, + ], +}