drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
290 stars 17 forks source link

Issue when running drizzle-kit studio out of docker #286

Open jakeleventhal opened 8 months ago

jakeleventhal commented 8 months ago

In docker, I specify the host as --host=0.0.0.0 and it says i can access the studio at https://local.drizzle.studio?host=0.0.0.0; however, when 4983 is exposed, the only way to access the studio is by using https://local.drizzle.studio?host=localhost.

It's a bit counterintuitive.

RobRoseKnows commented 8 months ago

I was also struggling to figure out how to run the studio out of docker. Would be nice if there was a prebuilt docker image that I could plug into my docker-compose that would bring the studio up.

kroucher commented 8 months ago

+1 on the struggle.

drizzle-kit studio running in Docker container, with ports exposed: image

Web fails to load, spamming console with errors: image

deadcoder0904 commented 7 months ago

is there no solution to this at all?

also, is this in development or do you guys run drizzle studio in production too with database?

would love to see your docker-compose.yml as i'm trying to set this up.

jakeleventhal commented 7 months ago
  drizzle-studio:
    build:
      context: ../../
      dockerfile: ./path/to/Dockerfile
    ports:
      - 4983:4983
    environment:
      DATABASE_URL: postgresql://postgres:local@db:5432/postgres
      DATABASE_DIRECT_URL: postgresql://postgres:local@db:5432/postgres
    depends_on:
      setup-db:
        condition: service_completed_successfully
    restart: always
    command: drizzle-kit studio --host=0.0.0.0
FROM node:18.17.1-alpine

WORKDIR /app

# Install dependencies
COPY packages/artelo/database/package.json ./database-package.json
RUN npm install -g \
  "pg@$(grep -E '"pg": "(.*)"' database-package.json | cut -d: -f2 | sed 's/,//' | xargs)" \
  "drizzle-kit@$(grep -E '"drizzle-kit": "(.*)"' database-package.json | cut -d: -f2 | sed 's/,//' | xargs)" \
  "drizzle-orm@$(grep -E '"drizzle-orm": "(.*)"' database-package.json | cut -d: -f2 | sed 's/,//' | xargs)"
RUN npm install "drizzle-orm@$(grep -E '"drizzle-orm": "(.*)"' database-package.json | cut -d: -f2 | sed 's/,//' | xargs)"

# Copy source files
COPY apps/myapp/package.json ./
COPY packages/myapp/database/drizzle.config.ts ./
COPY packages/myapp/database/src/schema.ts ./src/schema.ts
rickylabs commented 7 months ago

any news on this ?

huyhoang160593 commented 5 months ago

For anyone who struggle with this issue, the solution is rather simple. You need to isolate the drizzle kit studio into own service then set network_mode: host to that specific service, this will make the current service network not isolated from Docker host, which mean if you run drizzle-kit studio then the default port 4983 will be used, and no need to declare port options anymore. I have test this in my project and success

nelsonprsousa commented 5 months ago

For anyone who struggle with this issue, the solution is rather simple. You need to isolate the drizzle kit studio into own service then set network_mode: host to that specific service, this will make the current service network not isolated from Docker host, which mean if you run drizzle-kit studio then the default port 4983 will be used, and no need to declare port options anymore. I have test this in my project and success

Can you share your docker run command or docker-compose.yml file, please?

huyhoang160593 commented 5 months ago

@nelsonprsousa yeah sure. You can check out my repo here, the latest commit is for running drizzle-studio with docker alone

nelsonprsousa commented 5 months ago

@nelsonprsousa yeah sure. You can check out my repo here, the latest commit is for running drizzle-studio with docker alone

Thanks for sharing

jakeleventhal commented 5 months ago

Doesn't seem to work for me ¯_(ツ)_/¯

iurych commented 2 weeks ago

that is not simple at all

For anyone who struggle with this issue, the solution is rather simple. You need to isolate the drizzle kit studio into own service then set network_mode: host to that specific service, this will make the current service network not isolated from Docker host, which mean if you run drizzle-kit studio then the default port 4983 will be used, and no need to declare port options anymore. I have test this in my project and success

that is not simple at all

deadlinecode commented 1 week ago

For me it actually works running a bun container in my WSL i can access drizzle studio in the Browser However when starting it this way it needs like 30s before it actually connects and when connected nearly every request gets a CORS Error only every 4 Requests or so the Request actually goes through