Skip to content

Selfhosted docker unable to run as non-root user #302

@retrodaredevil

Description

@retrodaredevil

I am unable to run sourcebot as a non-root user. This is the error message I get when attempting to use a different user:

[Warning] AUTH_SECRET is not set.
[Info] Loading environment variables from /data/sourcebot/.authjs-secret
[Warning] AUTH_URL is not set.
[Info] Running database migration...
[Info] Running database migration...
Internal Error: EACCES: permission denied, open '/app/.yarn/install-state.gz'
Error: EACCES: permission denied, open '/app/.yarn/install-state.gz'
Internal Error: EACCES: permission denied, open '/app/.yarn/install-state.gz'
Error: EACCES: permission denied, open '/app/.yarn/install-state.gz'
sourcebot exited with code 0

It seems that everything in /app has root:root ownership, but it looks like non-root users should still be able to read the files in /app, so I'm not really sure what the problem is.

For reference:

/app # ls -la /app/.yarn/install-state.gz
-rw-r--r--    1 root     root       1331645 May 10 13:36 /app/.yarn/install-state.gz

Here's my overly complex docker compose file if anyone was curious:

# Sourcebot
# config.json docs: https://docs.sourcebot.dev/self-hosting/more/declarative-config
services:
  sourcebot:
    container_name: sourcebot
    image: ghcr.io/sourcebot-dev/sourcebot:latest
    restart: unless-stopped
    # TODO raise an issue to allow running as non-root - some permission error occurs
    #user: 2414:2414
    user: 0:0
    networks:
      - caddy_net-sourcebot
      - default
#    ports:
#      - "3000:3000"
    env_file:
      - ../timezone.env
    environment:
      - CONFIG_PATH=/config/config.json
      - DATA_DIR=/data
      - DATA_CACHE_DIR=/data/sourcebot
      - SOURCEBOT_TELEMETRY_DISABLED=true
      - DATABASE_URL=postgresql://postgres@postgres/sourcebot
      - REDIS_URL=redis://redis:6379
    volumes:
      - "/opt/containers/sourcebot/data:/data"
      - "./config:/config:ro"
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:3000/api/health || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    depends_on:
      - postgres
      - redis
  postgres:
    image: postgres:17-alpine
    restart: unless-stopped
    user: 2414:2414
    env_file:
      - ../timezone.env
    environment:
      - POSTGRES_DB=sourcebot
      - POSTGRES_HOST_AUTH_METHOD=trust
    volumes:
      - "/opt/containers/sourcebot/db:/var/lib/postgresql/data"
  redis:
    image: redis:8.0-alpine
    restart: unless-stopped
    user: 2414:2414
    env_file:
      - ../timezone.env
    volumes:
      - "/opt/containers/sourcebot/redis:/data"
networks:
  caddy_net-sourcebot:
    name: caddy_net-sourcebot
    external: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions