push
This commit is contained in:
6
server/.dockerignore
Normal file
6
server/.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
||||
node_modules
|
||||
dist
|
||||
.env
|
||||
npm-debug.log
|
||||
coverage
|
||||
.git
|
||||
44
server/Dockerfile
Normal file
44
server/Dockerfile
Normal 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"]
|
||||
12
server/docker-entrypoint.sh
Normal file
12
server/docker-entrypoint.sh
Normal 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
|
||||
Reference in New Issue
Block a user