diff --git a/definition-web-ui b/definition-web-ui index 1a8d784..4c42427 100644 --- a/definition-web-ui +++ b/definition-web-ui @@ -1,4 +1,4 @@ { "schemaVersion": 2, - "dockerfilePath": "./src/Managing.WebApp/Dockerfile" + "dockerfilePath": "./src/Managing.WebApp/Dockerfile-web-ui-dev" } \ No newline at end of file diff --git a/src/Managing.WebApp/Dockerfile-web-ui-dev b/src/Managing.WebApp/Dockerfile-web-ui-dev new file mode 100644 index 0000000..88c921a --- /dev/null +++ b/src/Managing.WebApp/Dockerfile-web-ui-dev @@ -0,0 +1,43 @@ +ARG NODE_VERSION=21.4.0 +ARG ALPINE_VERSION=3.19.0 + +FROM node:${NODE_VERSION}-alpine AS node + +FROM alpine:${ALPINE_VERSION} AS builder + +COPY --from=node /usr/lib /usr/lib +COPY --from=node /usr/local/lib /usr/local/lib +COPY --from=node /usr/local/include /usr/local/include +COPY --from=node /usr/local/bin /usr/local/bin + +RUN node -v + +# Set the working directory in the container +WORKDIR /app + +# Copy the package.json and package-lock.json first to leverage Docker's cache +COPY ./src/Managing.WebApp/package*.json ./ + +# Install dependencies +RUN npm i --omit=dev + +# Copy the application code +COPY . . + +# Build the Vite application +RUN npm run build + +# Stage 2: Create the runtime image +FROM nginx:alpine + +# Copy the built Vite application from the builder stage +COPY --from=builder /app/dist /usr/share/nginx/html + +# Copy a custom Nginx configuration file (if you need one) +# COPY nginx.conf /etc/nginx/nginx.conf + +# Expose port 80 +EXPOSE 80 + +# Start the Nginx server +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file