Skip to content
Snippets Groups Projects
Commit 7e74f44d authored by michael.minelli's avatar michael.minelli
Browse files

Dockerfile => Remove database migration stage and integrate it in the run

parent a4b5aa5e
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ ARG BUILD_WORKDIR=/dojo/ExpressAPI ...@@ -2,7 +2,6 @@ ARG BUILD_WORKDIR=/dojo/ExpressAPI
######################################################################## Build stage ######################################################################## Build stage
FROM node:20-bullseye AS builder FROM node:20-bullseye AS builder
LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>" LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>"
...@@ -24,24 +23,6 @@ RUN npm run build ...@@ -24,24 +23,6 @@ RUN npm run build
######################################################################## Database migration stage
FROM node:20-bullseye AS database-migration
LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>"
LABEL Description="Express API for Dojo - Database migration stage"
ARG BUILD_WORKDIR
COPY --from=builder ${BUILD_WORKDIR}/ ${BUILD_WORKDIR}/
WORKDIR ${BUILD_WORKDIR}
# Database migration
RUN npm run database:deploy
######################################################################## Run stage ######################################################################## Run stage
FROM node:20-bullseye FROM node:20-bullseye
LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>" LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>"
...@@ -49,13 +30,13 @@ LABEL Description="Express API for Dojo - Run stage" ...@@ -49,13 +30,13 @@ LABEL Description="Express API for Dojo - Run stage"
ARG BUILD_WORKDIR ARG BUILD_WORKDIR
COPY --from=database-migration ${BUILD_WORKDIR}/node_modules ./node_modules COPY --from=builder ${BUILD_WORKDIR}/node_modules ./node_modules
COPY --from=database-migration ${BUILD_WORKDIR}/package*.json ./ COPY --from=builder ${BUILD_WORKDIR}/package*.json ./
COPY --from=database-migration ${BUILD_WORKDIR}/dist ./dist COPY --from=builder ${BUILD_WORKDIR}/dist ./dist
COPY --from=database-migration ${BUILD_WORKDIR}/prisma ./prisma COPY --from=builder ${BUILD_WORKDIR}/prisma ./prisma
COPY --from=database-migration ${BUILD_WORKDIR}/.env ./.env COPY --from=builder ${BUILD_WORKDIR}/.env ./.env
EXPOSE 30992 EXPOSE 30992
CMD [ "npm", "run", "start:prod" ] CMD [ "npm", "run", "start:migrate:prod" ]
#ENTRYPOINT ["tail", "-f", "/dev/null"] #ENTRYPOINT ["tail", "-f", "/dev/null"]
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
"database:seed" : "npx prisma db seed", "database:seed" : "npx prisma db seed",
"database:deploy" : "npm run database:migrate && npm run database:seed", "database:deploy" : "npm run database:migrate && npm run database:seed",
"start:dev" : "npx nodemon src/app.ts", "start:dev" : "npx nodemon src/app.ts",
"start:prod" : "NODE_ENV=production npx node --max-http-header-size=1048576 dist/app.js" "start:prod" : "NODE_ENV=production npx node --max-http-header-size=1048576 dist/app.js",
"start:migrate:prod": "npm run database:deploy && npm run start:prod"
}, },
"prisma" : { "prisma" : {
"seed": "ts-node prisma/seed.ts" "seed": "node dist/prisma/seed"
}, },
"dependencies" : { "dependencies" : {
"@prisma/client" : "^4.16.2", "@prisma/client" : "^4.16.2",
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
} }
}, },
"include": [ "include": [
"src/**/*" "src/**/*",
"prisma/seed.ts"
], ],
"exclude": [ "exclude": [
] ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment