From bec242d841820d26bb47f971cc2ebe0646b8e733 Mon Sep 17 00:00:00 2001 From: Oscar Vicente Perez Date: Mon, 14 Aug 2023 16:28:23 +0200 Subject: [PATCH] Add first docker and docker-compose support --- .env | 1 + Dockerfile | 21 +++++++++++++++++++++ README.md | 2 +- docker-compose.yml | 18 ++++++++++++++++++ run.sh | 5 +++++ 5 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .env create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 run.sh diff --git a/.env b/.env new file mode 100644 index 0000000..33e26fc --- /dev/null +++ b/.env @@ -0,0 +1 @@ +GENERIC_TIMEZONE=UTC diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bbe7543 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM docker.n8n.io/n8nio/n8n:latest AS target + +FROM node:19-alpine AS build +RUN npm i npm@latest -g +WORKDIR /build +COPY . . + +RUN npm run build + +FROM target as final +WORKDIR /custom-nodes + +COPY --from=build /build . +COPY --from=build /build/run.sh /run.sh + +WORKDIR /custom-nodes +USER root +RUN npm link + +USER node +ENTRYPOINT [ "tini", "--", "/run.sh" ] diff --git a/README.md b/README.md index 43f0671..a69aecc 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ These are the basic steps for working with the starter. For detailed guidance on 3. Run `npm i` to install dependencies. 4. Open the project in your editor. 5. Browse the examples in `/nodes` and `/credentials`. Modify the examples, or replace them with your own nodes. -6. Update the `package.json` to match your details. +6. Update the `package.json` to match your details. Also update the `run.sh` with your package (In `package.json` => "name") name. 7. Run `npm run lint` to check for errors or `npm run lintfix` to automatically fix errors when possible. 8. Test your node locally. Refer to [Run your node locally](https://docs.n8n.io/integrations/creating-nodes/test/run-node-locally/) for guidance. 9. Replace this README with documentation for your node. Use the [README_TEMPLATE](README_TEMPLATE.md) to get started. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f5dcd69 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3" + +services: + n8n: + image: n8n-custom-nodes + restart: unless-stopped + build: . + ports: + - "5678:5678" + environment: + - GENERIC_TIMEZONE=${GENERIC_TIMEZONE} + - N8N_LOG_LEVEL=debug + volumes: + - n8n-data:/home/node/.n8n + +volumes: + n8n-data: + name: n8n-data diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..eaf9ee4 --- /dev/null +++ b/run.sh @@ -0,0 +1,5 @@ +#!/bin/sh +mkdir -p ~/.n8n/nodes/ +cd ~/.n8n/nodes/ +npm link n8n-nodes-<...> +/docker-entrypoint.sh