From 9075516a3e49d8dcf78d2429f2ce5fbc0313ca4a Mon Sep 17 00:00:00 2001 From: Mirko Mollik Date: Mon, 28 Oct 2024 18:18:34 +0100 Subject: [PATCH] docker (#122) Signed-off-by: Mirko Mollik --- .dockerignore | 2 ++ viewer/Dockerfile => Dockerfile | 16 +++++++++------- viewer/.dockerignore | 2 -- 3 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 .dockerignore rename viewer/Dockerfile => Dockerfile (60%) delete mode 100644 viewer/.dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..90bd0a0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +viewer/node_modules/ +viewer/dist/ diff --git a/viewer/Dockerfile b/Dockerfile similarity index 60% rename from viewer/Dockerfile rename to Dockerfile index 8adbab0..94f30ed 100644 --- a/viewer/Dockerfile +++ b/Dockerfile @@ -4,17 +4,17 @@ FROM node:18-alpine AS build # Set the working directory WORKDIR /app -# Copy the package.json and package-lock.json files -COPY package*.json ./ +# Copy package.json and package-lock.json first to leverage Docker caching +COPY viewer/package*.json ./viewer/ # Install dependencies -RUN npm ci +RUN cd viewer && npm ci # Copy the rest of the application code COPY . . # Build the Angular application -RUN npm run build:ssr +RUN cd viewer && npm run build:ssr # Stage 2: Serve the application using Node.js FROM node:18-alpine @@ -23,14 +23,16 @@ FROM node:18-alpine WORKDIR /app # Copy the built application from the previous stage -COPY --from=build /app/dist /app/dist +COPY --from=build /app/viewer/dist /app/dist + +# Copy package.json and package-lock.json for production dependencies +COPY viewer/package*.json ./ # Install only production dependencies -COPY package*.json ./ RUN npm install --only=production # Expose the port the app runs on EXPOSE 4000 # Start the application -CMD ["npm", "run", "serve:ssr:viewer"] +CMD ["npm", "run", "serve:ssr:viewer"] \ No newline at end of file diff --git a/viewer/.dockerignore b/viewer/.dockerignore deleted file mode 100644 index b947077..0000000 --- a/viewer/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -dist/