feat: cleanup docker setup
- Add .dockerignore - Replace .env with .env.example - Add migrations service - Cleanup Dockerfile: simpler setup, simpler copy, no migrations inside the image - Update README to match new instruction
This commit is contained in:
parent
c92b169435
commit
1d4251c23e
6 changed files with 90 additions and 46 deletions
29
Dockerfile
29
Dockerfile
|
|
@ -1,31 +1,26 @@
|
|||
FROM node:20-alpine AS build
|
||||
FROM node:20.11-bullseye AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
RUN apk update && \
|
||||
apk add --no-cache openssl python3 make g++ \
|
||||
&& ln -sf python3 /usr/bin/python
|
||||
|
||||
# Copy package files and install dependencies
|
||||
COPY package.json package-lock.json ./
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
# Copy application files
|
||||
COPY src/ src/
|
||||
COPY scripts/ scripts/
|
||||
COPY prisma/schema.prisma prisma/
|
||||
COPY tsconfig.json ./
|
||||
COPY . .
|
||||
|
||||
# Generate prisma client and build the application
|
||||
RUN npx prisma generate
|
||||
RUN npm run build
|
||||
|
||||
# Runtime stage
|
||||
FROM node:20-alpine
|
||||
FROM node:20.11-alpine as runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk update && \
|
||||
apk add --no-cache openssl
|
||||
apk add --no-cache openssl && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Copy built files from the build stage
|
||||
COPY --from=build /app .
|
||||
|
|
@ -33,11 +28,7 @@ COPY --from=build /app .
|
|||
# Install only runtime dependencies
|
||||
RUN npm install --only=production
|
||||
|
||||
# Copy and run migrations
|
||||
COPY --from=build /app/prisma ./prisma
|
||||
RUN npx prisma migrate deploy
|
||||
RUN npx prisma db push
|
||||
EXPOSE 3000
|
||||
|
||||
# Set entrypoint
|
||||
ENTRYPOINT [ "node", "scripts/start.js" ]
|
||||
ENTRYPOINT [ "node", "./dist/index.js" ]
|
||||
CMD ["start"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue