Search code examples
docker-composegithub-actionsn8n

Why is n8n failing in a GitHub pipeline but not locally?


We have a docker compose which we need for testing of our code. When we run it locally (macOS, different hosts) it works fine, however as soon as we run it on a GitHub action runner, it fails with

Error: EACCES: permission denied, open '/home/node/.n8n/config'

The affected service is an n8n container, which should expose an HTTP API, which also works locally.

  n8n:
    image: docker.n8n.io/n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=n8n:5678
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - DB_TYPE=postgresdb
      - DB_TABLE_PREFIX=n8n_
      - DB_POSTGRESDB_DATABASE=n8n
    volumes:
      - ./DOCKER/n8n/data:/home/node/.n8n
      - ./DOCKER/n8n/files:/files

The GitHub action pipeline works like this:

sudo useradd -m node
mkdir -p DOCKER/n8n
sudo chmod -R 777 DOCKER/n8n
sudo chown -R node:node DOCKER/n8n
docker-compose up -d

I added the overkill rights of 777 to debug, it also didn't work before that. But this way I ensure that theoretically it should have all the access it needs. I also removed the chown, did the chown with runner:runner and the current version, all of which are failing with the same message.

This is a follow-up to my question here: n8n in GitHub pipeline fails to expose port where it seemed like the port was closed. I found out that it is the container which is not starting and strangely not throwing any errors for this.


Solution

  • According to this guide on the official docs (thanks to this tread: https://github.com/n8n-io/n8n/issues/8272) volume mounts should be used. In my case to not obscure the folder structure etc. I did it in this form:

    volumes:
      n8n_data:
        driver: local
        driver_opts:
          type: none
          o: bind
          device: ./DOCKER/n8n/data