Final Project Tree
n8n-project/
├── docker-build.sh
├── Dockerfile
└── fly.toml
Setting up
mkdir n8n-project && cd n8n-project
touch fly.toml
fly.toml
file
# fly.toml app configuration file generated for n8n-ampersanda on 2023-09-26T12:45:18+07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = "n8n-project"
primary_region = "sin"
kill_signal = "SIGINT"
kill_timeout = "5s"
[experimental]
auto_rollback = true
[build]
# I'm using modified image, see Dockerfile
# or use from the n8n one
image = "ampersanda/n8n:latest"
[env]
GENERIC_TIMEZONE = "Asia/Jakarta"
N8N_DIAGNOSTICS_ENABLED = "false"
N8N_HIRING_BANNER_ENABLED = "false"
N8N_HOST = "n8n-project.fly.dev" # replace with n8n hostname
TINI_SUBREAPER = "true"
WEBHOOK_URL = "https://n8n-project.fly.dev" # replace with n8n hostname
[[mounts]]
source = "n8n_vol" # replace with volume name created before
destination = "/home/node/.n8n"
[[services]]
protocol = "tcp"
internal_port = 5678
processes = ["app"]
[[services.ports]]
port = 80
handlers = ["http"]
force_https = true
[[services.ports]]
port = 443
handlers = ["tls", "http"]
[services.concurrency]
type = "connections"
hard_limit = 25
soft_limit = 20
[[services.tcp_checks]]
interval = "15s"
timeout = "2s"
grace_period = "1s"
Dockerfile
file for image modification
Install additional things if you have customized image
FROM n8nio/n8n
USER root
RUN apk --update add curl python3 ffmpeg bash unzip gnupg \
chromium \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont \
nodejs \
yarn \
&& yarn add puppeteer \
&& yarn cache clean \
&& apk del --no-cache make gcc g++ python3
RUN wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
RUN chmod a+rx /usr/local/bin/youtube-dl
RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-puppeteer
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
CHROMIUM_PATH=/usr/bin/chromium-browser \
NODE_OPTIONS='--max_old_space_size=8000'
docker-build.sh
Build script to upload and update custom n8n package to Docker
docker pull docker.n8n.io/n8nio/n8n
docker buildx build -t ampersanda/n8n --platform=linux/amd64 --push .
Deployment
flyctl launch --no-deploy
flyctl volumes create n8n_vol --size 1 -r sin # "sin" is for Singapore, change for desired region
flyctl deploy
# optional, scale memory
flyctl scale memory 512 -a n8n-project