From 1d73f8d46487b3f3a3ab77079a893376101687e0 Mon Sep 17 00:00:00 2001 From: SquiddyPoos Date: Sat, 16 Sep 2023 21:03:40 +0800 Subject: [PATCH] update dockerfile --- Dockerfile | 11 ++++++++--- backend/package.json | 2 +- docker-compose.yml | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index f3e6e77..5ce6970 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,13 @@ -FROM node:14 -WORKDIR /usr/src/app -COPY . . +FROM node:14-alpine as build +WORKDIR /app +COPY ./frontend . +RUN npm install +RUN npm run build +FROM node:14-alpine as deploy WORKDIR /usr/src/app/backend +COPY ./backend . +COPY --from=build /app/dist ./public RUN npm run docker EXPOSE 8080 CMD [ "npm", "start" ] \ No newline at end of file diff --git a/backend/package.json b/backend/package.json index d8f6559..fd31dc1 100644 --- a/backend/package.json +++ b/backend/package.json @@ -11,7 +11,7 @@ "build_front": "cd ../frontend && npm install && npm run build && node copy.js", "start": "node dist/bin/www", "test": "echo \"Error: no test specified\" && exit 1", - "docker": "npm install && npm run build" + "docker": "npm install && tsc" }, "dependencies": { "apicache": "^1.6.2", diff --git a/docker-compose.yml b/docker-compose.yml index efc2fb8..ea1db87 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: 2 +version: "3.8" networks: primary: