docker: Coolify対応のためDockerfileビルドに移行しbind mount依存を排除
- ルートDockerfileで npm ci をビルド時に一元実行(node_modulesの競合破損を防止) - web/api/workerをYAMLアンカーで共通ビルド構成に変更し、.:/workspace のbind mountを削除 - vinextは --hostname でバインド指定(--host は無視される) - minio-initを削除(APIがbucketを自動作成)し、MinIOをexposeのみの内部公開に変更 - .dockerignore を追加し、.wranglerディレクトリをDockerfile内で事前作成
This commit is contained in:
+38
-52
@@ -3,14 +3,24 @@
|
||||
# Environment Variables / secrets panel.
|
||||
#
|
||||
# Coolify notes:
|
||||
# - All credentials are parameterized; set them in Coolify's env to avoid
|
||||
# the insecure local defaults.
|
||||
# - MinIO has a real healthcheck, so api/worker wait until it can serve.
|
||||
# - The API also creates the S3 bucket itself on startup (ensureBucket),
|
||||
# so the stack no longer depends on minio-init completing successfully.
|
||||
# - If you expose MinIO through a domain, set MINIO_SERVER_URL (public S3 API
|
||||
# origin) and MINIO_BROWSER_REDIRECT_URL (public console origin) so
|
||||
# presigned upload URLs and console redirects work from the browser.
|
||||
# - web/api/worker are all built from the same root Dockerfile and run from
|
||||
# the image contents. There are no bind mounts, so nothing depends on
|
||||
# Coolify mounting the git repository at /workspace (relative paths are
|
||||
# mounted as empty named volumes there).
|
||||
# - node_modules is baked into the image once by `npm ci` at build time, so
|
||||
# the containers never race each other running npm install.
|
||||
# - MinIO is fully private: uploads always flow through the API (browser ->
|
||||
# API -> MinIO) and the API creates its bucket on startup, so no
|
||||
# minio-init container and no published MinIO ports/domain are required.
|
||||
# - postgres published port exists only for local development; on Coolify,
|
||||
# public traffic goes through its reverse proxy and MinIO stays internal.
|
||||
|
||||
x-altdock-app: &altdock-app
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
working_dir: /workspace
|
||||
restart: unless-stopped
|
||||
|
||||
services:
|
||||
postgres:
|
||||
@@ -35,12 +45,11 @@ services:
|
||||
environment:
|
||||
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
|
||||
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin123}
|
||||
# Public origins, only needed when MinIO is behind a reverse proxy/domain.
|
||||
MINIO_SERVER_URL: ${MINIO_SERVER_URL:-}
|
||||
MINIO_BROWSER_REDIRECT_URL: ${MINIO_BROWSER_REDIRECT_URL:-}
|
||||
ports:
|
||||
- "9000:9000"
|
||||
- "9001:9001"
|
||||
# Internal-only: the API reaches MinIO over the compose network and uploads
|
||||
# are proxied through the API, so no host ports / public domain are needed.
|
||||
expose:
|
||||
- "9000"
|
||||
- "9001"
|
||||
volumes:
|
||||
- minio-data:/data
|
||||
healthcheck:
|
||||
@@ -50,35 +59,16 @@ services:
|
||||
retries: 12
|
||||
start_period: 10s
|
||||
|
||||
# Optional belt-and-suspenders: pre-creates the bucket. The API does the
|
||||
# same on startup, so this can be removed without affecting functionality.
|
||||
minio-init:
|
||||
image: minio/mc:latest
|
||||
depends_on:
|
||||
minio:
|
||||
condition: service_healthy
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
command: >-
|
||||
"until mc alias set local http://minio:9000 ${MINIO_ROOT_USER:-minioadmin} ${MINIO_ROOT_PASSWORD:-minioadmin123}; do sleep 1; done;
|
||||
mc mb --ignore-existing local/${S3_BUCKET:-altdock}"
|
||||
environment:
|
||||
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
|
||||
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin123}
|
||||
|
||||
api:
|
||||
image: node:22-bookworm
|
||||
working_dir: /workspace
|
||||
command: sh -c "npm install --no-audit --no-fund && npm run dev:api"
|
||||
<<: *altdock-app
|
||||
command: sh -c "npm run db:migrate && exec npm run dev:api"
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
PORT: 4000
|
||||
PUBLIC_BASE_URL: ${PUBLIC_BASE_URL:-http://localhost:4000}
|
||||
WEB_ORIGIN: ${WEB_ORIGIN:-http://localhost:3000}
|
||||
DATABASE_URL: postgres://${POSTGRES_USER:-altdock}:${POSTGRES_PASSWORD:-altdock}@postgres:5432/${POSTGRES_DB:-altdock}
|
||||
STORAGE_MODE: s3
|
||||
# S3_ENDPOINT is the internal address; presigned URLs resolve via the
|
||||
# public MINIO_SERVER_URL when set.
|
||||
S3_ENDPOINT: ${S3_ENDPOINT:-http://minio:9000}
|
||||
# Internal address only; uploads are proxied through the API, so MinIO
|
||||
# never needs a public URL.
|
||||
S3_ENDPOINT: http://minio:9000
|
||||
S3_REGION: ${S3_REGION:-us-east-1}
|
||||
S3_BUCKET: ${S3_BUCKET:-altdock}
|
||||
S3_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minioadmin}
|
||||
@@ -86,10 +76,10 @@ services:
|
||||
S3_FORCE_PATH_STYLE: "true"
|
||||
AUTH_MODE: ${AUTH_MODE:-demo}
|
||||
PROCESS_INLINE: "false"
|
||||
PUBLIC_BASE_URL: ${PUBLIC_BASE_URL:-http://localhost:4000}
|
||||
WEB_ORIGIN: ${WEB_ORIGIN:-http://localhost:3000}
|
||||
ports:
|
||||
- "4000:4000"
|
||||
volumes:
|
||||
- .:/workspace
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
@@ -97,14 +87,12 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
worker:
|
||||
image: node:22-bookworm
|
||||
working_dir: /workspace
|
||||
command: sh -c "npm install --no-audit --no-fund && npm run dev:worker"
|
||||
<<: *altdock-app
|
||||
command: npm run dev:worker
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
DATABASE_URL: postgres://${POSTGRES_USER:-altdock}:${POSTGRES_PASSWORD:-altdock}@postgres:5432/${POSTGRES_DB:-altdock}
|
||||
STORAGE_MODE: s3
|
||||
S3_ENDPOINT: ${S3_ENDPOINT:-http://minio:9000}
|
||||
S3_ENDPOINT: http://minio:9000
|
||||
S3_REGION: ${S3_REGION:-us-east-1}
|
||||
S3_BUCKET: ${S3_BUCKET:-altdock}
|
||||
S3_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minioadmin}
|
||||
@@ -112,8 +100,6 @@ services:
|
||||
S3_FORCE_PATH_STYLE: "true"
|
||||
AUTH_MODE: ${AUTH_MODE:-demo}
|
||||
PROCESS_INLINE: "false"
|
||||
volumes:
|
||||
- .:/workspace
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
@@ -121,15 +107,15 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
web:
|
||||
image: node:22-bookworm
|
||||
working_dir: /workspace
|
||||
command: sh -c "npm install --no-audit --no-fund && npm run dev -- --host 0.0.0.0"
|
||||
<<: *altdock-app
|
||||
# vinext uses --hostname (not vite's --host) to bind the dev server.
|
||||
command: npm run dev -- --hostname 0.0.0.0
|
||||
environment:
|
||||
HOST: 0.0.0.0
|
||||
NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL:-http://localhost:4000}
|
||||
NEXT_PUBLIC_AUTH_MODE: ${AUTH_MODE:-demo}
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- .:/workspace
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_started
|
||||
|
||||
Reference in New Issue
Block a user