DEV Community

Cover image for Como configurar o n8n localmente com docker compose
Weverton Souza
Weverton Souza

Posted on

Como configurar o n8n localmente com docker compose

Clonar repositório n8n e configuração

git clone https://github.com/n8n-io/n8n-docker-caddy.git

cd n8n-docker-caddy
docker volume create caddy_data
sudo docker volume create n8n_data
Enter fullscreen mode Exit fullscreen mode

Editar arquivos de configuração

nano .env

# Replace <directory-path> with the path where you created folders earlier
DATA_FOLDER=/home/weverton/Projetos/n8n-local2/n8n-docker-caddy

# The top level domain to serve from, this should be the same as the subdomain you created above
DOMAIN_NAME=localhost

# The subdomain to serve from
SUBDOMAIN=

# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: https://n8n.example.com

# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=Europe/Berlin

# The email address to use for the SSL certificate creation
SSL_EMAIL=example@example.com

Enter fullscreen mode Exit fullscreen mode

nano docker-compose.yml

version: "3.7"

services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - caddy_data:/data
      - ${DATA_FOLDER}/caddy_config:/config
      - ${DATA_FOLDER}/caddy_config/Caddyfile:/etc/caddy/Caddyfile

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - 5678:5678
    environment:
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - WEBHOOK_URL=http://localhost/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ${DATA_FOLDER}/local_files:/files

volumes:
  caddy_data:
    external: true
  n8n_data:
    external: true
Enter fullscreen mode Exit fullscreen mode

nano caddy_config/Caddyfile

localhost {
    reverse_proxy n8n:5678 {
      flush_interval -1
    }
}
Enter fullscreen mode Exit fullscreen mode

Configuração de pasta

export DATA_FOLDER=/root/n8n-docker-caddy
mkdir -p /root/n8n-docker-caddy/.n8n
chown -R 1000:1000 /root/n8n-docker-caddy/.n8n
Enter fullscreen mode Exit fullscreen mode

Iniciar o Docker

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

tutorial em vídeo: https://youtu.be/fEP2r_V4Ehc?si=P46mNH-Jia61Drw8

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay