update dockerfile's

This commit is contained in:
MaKarin
2026-04-04 19:53:08 +03:00
parent fed445df7a
commit cf53ab8cf9
4 changed files with 24 additions and 10 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.sh text eol=lf

View File

@@ -40,16 +40,11 @@ services:
KEYCLOAK_JWKS_URL: ${KEYCLOAK_JWKS_URL:-} KEYCLOAK_JWKS_URL: ${KEYCLOAK_JWKS_URL:-}
healthcheck: healthcheck:
test: test:
[ ["CMD", "curl", "-fsS", "http://127.0.0.1:3000/health"]
"CMD",
"node",
"-e",
"fetch('http://127.0.0.1:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))",
]
interval: 15s interval: 15s
timeout: 5s timeout: 5s
retries: 5 retries: 5
start_period: 20s start_period: 90s
expose: expose:
- "3000" - "3000"
networks: networks:

View File

@@ -27,7 +27,7 @@ WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl \ && apt-get install -y --no-install-recommends openssl ca-certificates curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY --from=build /app/package*.json ./ COPY --from=build /app/package*.json ./

View File

@@ -1,8 +1,26 @@
#!/bin/sh #!/bin/sh
set -eu set -e
PRISMA_BIN="./node_modules/.bin/prisma"
if [ ! -f "$PRISMA_BIN" ]; then
echo "Prisma CLI not found at $PRISMA_BIN"
exit 1
fi
echo "Applying database migrations..." echo "Applying database migrations..."
npx prisma migrate deploy i=0
while [ "$i" -lt 15 ]; do
if "$PRISMA_BIN" migrate deploy; then
break
fi
i=$((i + 1))
if [ "$i" -eq 15 ]; then
echo "prisma migrate deploy failed after 15 attempts"
exit 1
fi
echo "Migrate failed or DB not ready; retrying in 2s ($i/15)..."
sleep 2
done
echo "Starting NestJS..." echo "Starting NestJS..."
exec node dist/main.js exec node dist/main.js