From a56ef1b06f2a4db338d893465fdbf826e3c219b9 Mon Sep 17 00:00:00 2001 From: webcoderz <19884161+webcoderz@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:15:46 -0400 Subject: [PATCH] adding local docker compose with local postgres --- docker-compose.yaml | 54 +++++++++++++++++++++++++++++++++++++ local/Dockerfile | 16 +++++++++++ local/scripts/entrypoint.sh | 9 +++++++ web/.env.local.example | 22 +++++++++++++++ web/src/db/db.ts | 4 +-- 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 docker-compose.yaml create mode 100644 local/Dockerfile create mode 100644 local/scripts/entrypoint.sh create mode 100644 web/.env.local.example diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..085b213 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,54 @@ +version: '3.9' +services: + + comfy-deploy: + build: + context: . + dockerfile: ./local/Dockerfile + restart: unless-stopped + volumes: + - ./local/scripts/entrypoint.sh:/comfyui-deploy/web/deploy_entrypoint.sh + entrypoint: /comfyui-deploy/web/deploy_entrypoint.sh + ports: + - 3000:3000 + depends_on: + - postgres + - pg_proxy + - localstack + environment: + VSCODE_DEV_CONTAINER: true + + +### comfy-deploy services + + postgres: + image: "postgres:15.2-alpine" + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: verceldb + expose: + - 5432 + + + pg_proxy: + image: ghcr.io/neondatabase/wsproxy:latest + environment: + APPEND_PORT: "postgres:5432" + ALLOW_ADDR_REGEX: ".*" + LOG_TRAFFIC: "true" + expose: + - 80 + depends_on: + - postgres + + + localstack: + image: localstack/localstack:latest + environment: + SERVICES: s3 + ports: + - 4566:4566 + volumes: + - ../localstack/aws:/etc/localstack/init/ready.d + - ../localstack/aws:/app/web/aws \ No newline at end of file diff --git a/local/Dockerfile b/local/Dockerfile new file mode 100644 index 0000000..cc62c19 --- /dev/null +++ b/local/Dockerfile @@ -0,0 +1,16 @@ +FROM node:21-bullseye AS comfy_deploy + + + +RUN npm install -g bun + +COPY ./web /web + + +WORKDIR /web + +RUN cp .env.local.example .env.local + +RUN bun i + +ENTRYPOINT [ "bun", "dev" ] \ No newline at end of file diff --git a/local/scripts/entrypoint.sh b/local/scripts/entrypoint.sh new file mode 100644 index 0000000..00154f1 --- /dev/null +++ b/local/scripts/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "comfy deploy container starting.." + +echo "Running migrations.." +bun migrate-local + +echo "Starting comfy deploy.." +bun dev \ No newline at end of file diff --git a/web/.env.local.example b/web/.env.local.example new file mode 100644 index 0000000..601045b --- /dev/null +++ b/web/.env.local.example @@ -0,0 +1,22 @@ +POSTGRES_SSL="false" +POSTGRES_URL="postgres://postgres:postgres@postgres:5432/verceldb" + +NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY= +CLERK_SECRET_KEY= + +SPACES_ENDPOINT="http://localhost:4566" +SPACES_ENDPOINT_CDN="http://localhost:4566" +SPACES_REGION="nyc3" +SPACES_BUCKET="comfyui-deploy" +SPACES_KEY="xyz" +SPACES_SECRET="aaa" +SPACES_CDN_DONT_INCLUDE_BUCKET="false" +SPACES_CDN_FORCE_PATH_STYLE="true" + +MODAL_BUILDER_URL= + +JWT_SECRET="openssl rand -hex 32" +PLAUSIBLE_DOMAIN= + +NEXT_PUBLIC_POSTHOG_KEY="your-api-key" +NEXT_PUBLIC_POSTHOG_HOST="your-ph-address" diff --git a/web/src/db/db.ts b/web/src/db/db.ts index 2cd8d5d..f1e791e 100644 --- a/web/src/db/db.ts +++ b/web/src/db/db.ts @@ -9,10 +9,10 @@ if (process.env.VERCEL_ENV !== "production") { // Set the WebSocket proxy to work with the local instance if (isDevContainer) { // Running inside a VS Code devcontainer - neonConfig.wsProxy = (host) => "host.docker.internal:5481/v1"; + neonConfig.wsProxy = (host) => "pg_proxy:80/v1"; } else { // Not running inside a VS Code devcontainer - neonConfig.wsProxy = (host) => `${host}:5481/v1`; + neonConfig.wsProxy = (host) => "pg_proxy:80/v1"; } // Disable all authentication and encryption neonConfig.useSecureWebSocket = false;