fix some for api container
This commit is contained in:
@@ -11,7 +11,7 @@ POSTGRES_PASSWORD=CHANGE_ME_STRONG_PASSWORD
|
|||||||
# اگر 5432 روی سرور اشغال است مثلاً بگذارید 15432
|
# اگر 5432 روی سرور اشغال است مثلاً بگذارید 15432
|
||||||
EXPORT_DB_PORT=15432
|
EXPORT_DB_PORT=15432
|
||||||
|
|
||||||
# داخل شبکه compose هاست postgres است (نه localhost)
|
# داخل شبکه compose هاست postgres است (نه localhost و نه IP عمومی)
|
||||||
DATABASE_URL=postgresql://postgres:CHANGE_ME_STRONG_PASSWORD@postgres:5432/lucky_wheel?schema=public
|
DATABASE_URL=postgresql://postgres:CHANGE_ME_STRONG_PASSWORD@postgres:5432/lucky_wheel?schema=public
|
||||||
|
|
||||||
REDIS_PASSWORD=
|
REDIS_PASSWORD=
|
||||||
|
|||||||
+2
-3
@@ -2,15 +2,14 @@ FROM docker.arvancloud.ir/node:20-bookworm
|
|||||||
|
|
||||||
# فقط کپی — هیچ install/build داخل ایمیج نیست.
|
# فقط کپی — هیچ install/build داخل ایمیج نیست.
|
||||||
# لوکال: pnpm run build:api:release
|
# لوکال: pnpm run build:api:release
|
||||||
# مهم: apps/api/release/node_modules باید داخل گیت باشد.
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
COPY apps/api/release/ ./
|
COPY apps/api/release/ ./
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# بهجای .bin (روی ویندوز shim میسازد) مستقیم entry لینوکسی Prisma
|
CMD ["sh", "/app/docker-entrypoint.sh"]
|
||||||
CMD ["sh", "-c", "node node_modules/prisma/build/index.js migrate deploy && node app.js"]
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "[api] starting entrypoint at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
echo "[api] node=$(node -v) cwd=$(pwd)"
|
||||||
|
echo "[api] release check: app.js=$(test -f app.js && echo yes || echo NO) prisma=$(test -f node_modules/prisma/build/index.js && echo yes || echo NO)"
|
||||||
|
|
||||||
|
if [ ! -f app.js ]; then
|
||||||
|
echo "[api] FATAL: app.js missing — release copy failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f node_modules/prisma/build/index.js ]; then
|
||||||
|
echo "[api] FATAL: prisma CLI missing — commit apps/api/release/node_modules" >&2
|
||||||
|
ls -la node_modules 2>&1 || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[api] REDIS_HOST=${REDIS_HOST:-unset} REDIS_PORT=${REDIS_PORT:-unset}"
|
||||||
|
|
||||||
|
echo "[api] running prisma migrate deploy..."
|
||||||
|
node node_modules/prisma/build/index.js migrate deploy --schema=./prisma/schema.prisma
|
||||||
|
echo "[api] migrate done"
|
||||||
|
|
||||||
|
echo "[api] launching app.js on 0.0.0.0:${PORT:-3000}"
|
||||||
|
exec node app.js
|
||||||
@@ -219153,9 +219153,9 @@ async function bootstrap() {
|
|||||||
const document2 = swagger_1.SwaggerModule.createDocument(app, swaggerConfig);
|
const document2 = swagger_1.SwaggerModule.createDocument(app, swaggerConfig);
|
||||||
swagger_1.SwaggerModule.setup("api/docs", app, document2);
|
swagger_1.SwaggerModule.setup("api/docs", app, document2);
|
||||||
const port = configService.get("PORT", 3e3);
|
const port = configService.get("PORT", 3e3);
|
||||||
await app.listen(port);
|
await app.listen(port, "0.0.0.0");
|
||||||
console.log(`Application is running on: http://localhost:${port}`);
|
console.log(`Application is running on: http://0.0.0.0:${port}`);
|
||||||
console.log(`Swagger documentation: http://localhost:${port}/api/docs`);
|
console.log(`Swagger documentation: http://0.0.0.0:${port}/api/docs`);
|
||||||
}
|
}
|
||||||
__name(bootstrap, "bootstrap");
|
__name(bootstrap, "bootstrap");
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "[api] starting entrypoint at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
echo "[api] node=$(node -v) cwd=$(pwd)"
|
||||||
|
echo "[api] release check: app.js=$(test -f app.js && echo yes || echo NO) prisma=$(test -f node_modules/prisma/build/index.js && echo yes || echo NO)"
|
||||||
|
|
||||||
|
if [ ! -f app.js ]; then
|
||||||
|
echo "[api] FATAL: app.js missing — release copy failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f node_modules/prisma/build/index.js ]; then
|
||||||
|
echo "[api] FATAL: prisma CLI missing — commit apps/api/release/node_modules" >&2
|
||||||
|
ls -la node_modules 2>&1 || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[api] REDIS_HOST=${REDIS_HOST:-unset} REDIS_PORT=${REDIS_PORT:-unset}"
|
||||||
|
|
||||||
|
echo "[api] running prisma migrate deploy..."
|
||||||
|
node node_modules/prisma/build/index.js migrate deploy --schema=./prisma/schema.prisma
|
||||||
|
echo "[api] migrate done"
|
||||||
|
|
||||||
|
echo "[api] launching app.js on 0.0.0.0:${PORT:-3000}"
|
||||||
|
exec node app.js
|
||||||
@@ -34,6 +34,9 @@ async function main() {
|
|||||||
}
|
}
|
||||||
cpSync(path.join(root, 'prisma'), prismaDest, { recursive: true });
|
cpSync(path.join(root, 'prisma'), prismaDest, { recursive: true });
|
||||||
|
|
||||||
|
// entrypoint برای لاگ واضح استارت در Dokploy
|
||||||
|
cpSync(path.join(root, 'docker-entrypoint.sh'), path.join(releaseDir, 'docker-entrypoint.sh'));
|
||||||
|
|
||||||
const releasePkg = {
|
const releasePkg = {
|
||||||
name: 'lucky-wheel-api-release',
|
name: 'lucky-wheel-api-release',
|
||||||
private: true,
|
private: true,
|
||||||
|
|||||||
@@ -77,9 +77,10 @@ async function bootstrap() {
|
|||||||
SwaggerModule.setup('api/docs', app, document);
|
SwaggerModule.setup('api/docs', app, document);
|
||||||
|
|
||||||
const port = configService.get<number>('PORT', 3000);
|
const port = configService.get<number>('PORT', 3000);
|
||||||
await app.listen(port);
|
// Dokploy/Traefik از شبکه Docker وصل میشود — باید روی همه اینترفیسها listen کند
|
||||||
console.log(`Application is running on: http://localhost:${port}`);
|
await app.listen(port, '0.0.0.0');
|
||||||
console.log(`Swagger documentation: http://localhost:${port}/api/docs`);
|
console.log(`Application is running on: http://0.0.0.0:${port}`);
|
||||||
|
console.log(`Swagger documentation: http://0.0.0.0:${port}/api/docs`);
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user