coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
34.99k stars 1.93k forks source link

[Bug]: Local Development With Mac #2382

Closed webdevcody closed 2 months ago

webdevcody commented 5 months ago

Description

I kept getting volume mount errors when trying to follow the spin up command because /data is not writable on mac. I modified the docker-compose.yml like this to get it working, but it would be cool if we had a documented approach to point to this .yml when doing local dev on mac; I'm too noob to the project to figure that out

services:
  coolify:
    build:
      context: .
      dockerfile: ./docker/dev/Dockerfile
    ports:
      - "${APP_PORT:-8000}:80"
    environment:
      PUID: "${USERID:-1000}"
      PGID: "${GROUPID:-1000}"
      SSL_MODE: "off"
      AUTORUN_LARAVEL_STORAGE_LINK: "false"
      AUTORUN_LARAVEL_MIGRATION: "false"
      PUSHER_HOST: "${PUSHER_HOST}"
      PUSHER_PORT: "${PUSHER_PORT}"
      PUSHER_SCHEME: "${PUSHER_SCHEME:-http}"
      PUSHER_APP_ID: "${PUSHER_APP_ID:-coolify}"
      PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
      PUSHER_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
    volumes:
      - .:/var/www/html/:cached
  postgres:
    pull_policy: always
    ports:
      - "${FORWARD_DB_PORT:-5432}:5432"
    env_file:
      - .env
    environment:
      POSTGRES_USER: "${DB_USERNAME:-coolify}"
      POSTGRES_PASSWORD: "${DB_PASSWORD:-password}"
      POSTGRES_DB: "${DB_DATABASE:-coolify}"
      POSTGRES_HOST_AUTH_METHOD: "trust"
    volumes:
      # - /data/coolify/_volumes/database/:/var/lib/postgresql/data
      - coolify-pg-data-dev:/var/lib/postgresql/data
  redis:
    pull_policy: always
    ports:
      - "${FORWARD_REDIS_PORT:-6379}:6379"
    env_file:
      - .env
    volumes:
      # - /data/coolify/_volumes/redis/:/data
      - coolify-redis-data-dev:/data
  soketi:
    env_file:
      - .env
    ports:
      - "${FORWARD_SOKETI_PORT:-6001}:6001"
    environment:
      SOKETI_DEBUG: "false"
      SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID:-coolify}"
      SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
      SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
  vite:
    image: node:20
    pull_policy: always
    working_dir: /var/www/html
    # environment:
    # VITE_PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
    ports:
      - "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
    volumes:
      - .:/var/www/html:cached
    command: sh -c "npm install && npm run dev"
    networks:
      - coolify
  testing-host:
    image: "ghcr.io/coollabsio/coolify-testing-host:latest"
    pull_policy: always
    init: true
    container_name: coolify-testing-host
    volumes:
      - /:/host
      - /var/run/docker.sock:/var/run/docker.sock
      - coolify-data-dev:/data/coolify
      # - /data/coolify/:/data/coolify
    networks:
      - coolify
  mailpit:
    image: "axllent/mailpit:latest"
    pull_policy: always
    container_name: coolify-mail
    ports:
      - "${FORWARD_MAILPIT_PORT:-1025}:1025"
      - "${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025"
    networks:
      - coolify
  minio:
    image: minio/minio:latest
    pull_policy: always
    container_name: coolify-minio
    command: server /data --console-address ":9001"
    ports:
      - "${FORWARD_MINIO_PORT:-9000}:9000"
      - "${FORWARD_MINIO_PORT_CONSOLE:-9001}:9001"
    environment:
      MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY:-minioadmin}"
      MINIO_SECRET_KEY: "${MINIO_SECRET_KEY:-minioadmin}"
    volumes:
      # - /data/coolify/_volumes/minio/:/data
      - coolify-minio-data-dev:/data
    networks:
      - coolify

volumes:
  coolify-data-dev:
  coolify-pg-data-dev:
  coolify-redis-data-dev:
  coolify-minio-data-dev:

networks:
  coolify:
    name: coolify
    external: false

Minimal Reproduction (if possible, example repository)

m

Exception or Error

No response

Version

next bramch

Thijmen commented 5 months ago

Have you tried to change /data to ./data? So it uses your current directory in stead of the root of your filesystem. Perhaps good to document this in the future.

peaklabs-dev commented 3 months ago

@webdevcody Is this still an issue because I can just clone the repo locally and run spin up, no modifications needed on my mac?

bufferhead-code commented 3 months ago

i also got those mounting errors.

when using some of the volumes that are commented out and adding the coolify-data-dev volume, i ended up with this docker-compose which seems to work for me:

services:
  coolify:
    build:
      context: .
      dockerfile: ./docker/dev/Dockerfile
    ports:
      - "${APP_PORT:-8000}:80"
    environment:
      PUID: "${USERID:-1000}"
      PGID: "${GROUPID:-1000}"
      SSL_MODE: "off"
      AUTORUN_LARAVEL_STORAGE_LINK: "false"
      AUTORUN_LARAVEL_MIGRATION: "false"
      PUSHER_HOST: "${PUSHER_HOST}"
      PUSHER_PORT: "${PUSHER_PORT}"
      PUSHER_SCHEME: "${PUSHER_SCHEME:-http}"
      PUSHER_APP_ID: "${PUSHER_APP_ID:-coolify}"
      PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
      PUSHER_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
    volumes:
      - .:/var/www/html/:cached
  postgres:
    pull_policy: always
    ports:
      - "${FORWARD_DB_PORT:-5432}:5432"
    env_file:
      - .env
    environment:
      POSTGRES_USER: "${DB_USERNAME:-coolify}"
      POSTGRES_PASSWORD: "${DB_PASSWORD:-password}"
      POSTGRES_DB: "${DB_DATABASE:-coolify}"
      POSTGRES_HOST_AUTH_METHOD: "trust"
    volumes:
      # this volume is changed
       - coolify-pg-data-dev:/var/lib/postgresql/data
  redis:
    pull_policy: always
    ports:
      - "${FORWARD_REDIS_PORT:-6379}:6379"
    env_file:
      - .env
    volumes:
      # this volume is changed
       - coolify-redis-data-dev:/data
  soketi:
    env_file:
      - .env
    ports:
      - "${FORWARD_SOKETI_PORT:-6001}:6001"
    environment:
      SOKETI_DEBUG: "false"
      SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID:-coolify}"
      SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
      SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
  vite:
    image: node:20
    pull_policy: always
    working_dir: /var/www/html
    # environment:
    # VITE_PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
    ports:
      - "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
    volumes:
      - .:/var/www/html:cached
    command: sh -c "npm install && npm run dev"
    networks:
      - coolify
  testing-host:
    image: "ghcr.io/coollabsio/coolify-testing-host:latest"
    pull_policy: always
    init: true
    container_name: coolify-testing-host
    volumes:
      - /:/host
      - /var/run/docker.sock:/var/run/docker.sock
      # this volume is changed
      - coolify-data-dev:/data/coolify
    networks:
      - coolify
  mailpit:
    image: "axllent/mailpit:latest"
    pull_policy: always
    container_name: coolify-mail
    ports:
      - "${FORWARD_MAILPIT_PORT:-1025}:1025"
      - "${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025"
    networks:
      - coolify
  minio:
    image: minio/minio:latest
    pull_policy: always
    container_name: coolify-minio
    command: server /data --console-address ":9001"
    ports:
      - "${FORWARD_MINIO_PORT:-9000}:9000"
      - "${FORWARD_MINIO_PORT_CONSOLE:-9001}:9001"
    environment:
      MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY:-minioadmin}"
      MINIO_SECRET_KEY: "${MINIO_SECRET_KEY:-minioadmin}"
    volumes:
      # this volume is changed
       - coolify-minio-data-dev:/data
    networks:
      - coolify

volumes:
  coolify-data-dev:
  coolify-pg-data-dev:
  coolify-redis-data-dev:
  coolify-minio-data-dev:

networks:
  coolify:
    name: coolify
    external: false
peaklabs-dev commented 2 months ago

This is a known compatibility issue between Coolify and Docker Desktop on Mac OS as Coolify mounts volumes for another container called coolify-testing-host . Please use Orbstack for now. I am working on a workaround.

peaklabs-dev commented 2 months ago

I have fixed this problem. Will be releasing a fix for this in the next version, which will be released Monday or Tuesday depending on our final testing.

ysfaran commented 2 months ago

@peaklabs-dev I think this is not 100% handled. Local development seems to be still buggy for some apps. For example if you add a mongo db it will not work for my Mac M2.

unix_listener: cannot bind to path /var/www/html/storage/app/ssh/mux/mux_mwsc08c4gcw8kg8gcgo48gw8.DPawdsLDqSriTywv: Invalid argument
ControlSocket /var/www/html/storage/app/ssh/mux/mux_mwsc08c4gcw8kg8gcgo48gw8.DPawdsLDqSriTywv already exists, disabling multiplexing
Starting mongodb-database-o0w0c8swks8oc4kg8k4k0ws8.
Pulling mongo:7 image.
 kw8coc8wc04c8808wkwg4k0c Pulling 
 kw8coc8wc04c8808wkwg4k0c Pulled 
 Volume "mongodb-configdb-kw8coc8wc04c8808wkwg4k0c"  Creating
 Volume "mongodb-configdb-kw8coc8wc04c8808wkwg4k0c"  Created
 Volume "mongodb-db-kw8coc8wc04c8808wkwg4k0c"  Creating
 Volume "mongodb-db-kw8coc8wc04c8808wkwg4k0c"  Created
 Container kw8coc8wc04c8808wkwg4k0c  Creating
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /data/coolify/databases/kw8coc8wc04c8808wkwg4k0c/docker-entrypoint-initdb.d

It produces this volumes statement for the mongo docker-compose.yml:

volumes:
            - 'mongodb-configdb-kw8coc8wc04c8808wkwg4k0c:/data/configdb'
            - 'mongodb-db-kw8coc8wc04c8808wkwg4k0c:/data/db'
            -
                type: bind
                source: /data/coolify/databases/kw8coc8wc04c8808wkwg4k0c/docker-entrypoint-initdb.d
                target: /docker-entrypoint-initdb.d
                read_only: true

I guess the issue is that it tries to find /data/coolify/databases/kw8coc8wc04c8808wkwg4k0c/docker-entrypoint-initdb.d on my Mac instead of the testing-host, because of the type: bind.

There is an open discord support question from me that explains this in more detail: https://discord.com/channels/459365938081431553/1291781262016774198/1291781262016774198

peaklabs-dev commented 2 months ago

I will check it. Are you using docker desktop?

ysfaran commented 2 months ago

I will check it. Are you using docker desktop?

yes

peaklabs-dev commented 1 month ago

@ysfaran I have opened a separate issue to track this, as I am pretty sure the issue is not related to this one, please use that one to track the resolution of the bug: https://github.com/coollabsio/coolify/issues/3918