Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding local docker compose with local postgres #39

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions local/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
9 changes: 9 additions & 0 deletions local/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

echo "comfy deploy container starting.."

echo "Running migrations.."
bun migrate-local

echo "Starting comfy deploy.."
bun dev
22 changes: 22 additions & 0 deletions web/.env.local.example
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could your references just use the existing web/.env.example https://github.com/BennyKok/comfyui-deploy/blob/main/web/.env.example

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea can just change the POSTGRES_PORT env of the local Postgres to reflect 5480 , the reason it’s different is because I’m not exposing Postgres to host network it’s only exposed internally

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also since it’s on internal network you can use the service name instead of localhost:5480.. eg. postgres:5480

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker file copies in the env.local env vars should I get rid of that also?

Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions web/src/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down