This commit is contained in:
MaKarin
2026-04-03 22:15:10 -07:00
parent 8a578baac0
commit 5000e6baa0
6 changed files with 122 additions and 0 deletions

6
server/.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
node_modules
dist
.env
npm-debug.log
coverage
.git

44
server/Dockerfile Normal file
View File

@@ -0,0 +1,44 @@
FROM node:20-bookworm-slim AS build
WORKDIR /app
ARG DATABASE_URL=postgresql://postgres:postgres@localhost:5432/toir
ENV DATABASE_URL=$DATABASE_URL
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl \
&& rm -rf /var/lib/apt/lists/*
COPY package*.json ./
COPY prisma ./prisma
RUN npm ci
COPY nest-cli.json tsconfig*.json prisma.config.ts ./
COPY src ./src
RUN npx prisma generate
RUN npm run build
FROM node:20-bookworm-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /app/package*.json ./
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/prisma ./prisma
COPY --from=build /app/prisma.config.ts ./prisma.config.ts
COPY --from=build /app/dist ./dist
COPY docker-entrypoint.sh ./docker-entrypoint.sh
RUN chmod +x ./docker-entrypoint.sh
EXPOSE 3000
CMD ["./docker-entrypoint.sh"]

View File

@@ -0,0 +1,12 @@
#!/bin/sh
set -eu
if [ -d "prisma/migrations" ] && [ -n "$(find prisma/migrations -mindepth 1 -maxdepth 1 -type d 2>/dev/null)" ]; then
echo "Applying Prisma migrations with migrate deploy..."
npx prisma migrate deploy
else
echo "No Prisma migrations found, syncing schema with db push..."
npx prisma db push
fi
exec node dist/src/main.js