-
-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Please add more details about when we have seeds. Personally I did this:
Dockerfile
# As you understood I have another base.Dockerfile to do npm ci and commit it as my base image. I did this because in my area Net bother me a lot and my image build time was around 20 min and mostly failed due to Socket timeout error while npm ci
# FROM node:16.14.0-alpine3.15 as build_stage
FROM take-report:dep as build_stage
# README: Because WORKDIR is set in the take-report:dep I ignore to use it here again
# WORKDIR /app
# When using COPY with more than one source file, the destination must be a directory and end with a /
COPY prisma ./prisma/
COPY . .
RUN npx prisma generate
RUN npm run build
# RUN npm prune --production
FROM node:16.14.0-alpine3.15
WORKDIR /app
COPY --from=build_stage /app/node_modules ./node_modules
COPY --from=build_stage /app/package*.json ./
COPY --from=build_stage /app/tsconfig*.json ./
COPY --from=build_stage /app/dist ./dist
COPY --from=build_stage /app/prisma ./prisma
EXPOSE $APP_PORTAnd this is my docker-compose.yml file:
version: '3.7'
services:
take-report:
image: take-report:v1
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile
args:
- DATABASE_URL
ports:
- ${APP_EXPOSED_PORT}:$APP_PORT
env_file:
- .env
networks:
- take-report
- traefik_default
labels:
- "traefik.enable=true"
command: npm run start:prisma:prodAnd in my package.json I have these scripts:
"start:prisma:prod": "npm run prisma:dev && node dist/src/main",
"prisma:dev": "npx prisma generate && npx prisma deploy && npx prisma db seed",But my problem with this solution is that I have to run npm prune --production after my seed completed. Do you have any idea to improve this?
Metadata
Metadata
Assignees
Labels
No labels