diff --git a/Dockerfile b/Dockerfile index ca6a9b1..769dce7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,37 @@ -FROM node:12-alpine +# Use Node 21 as the base image for the builder stage +FROM node:21-alpine AS builder LABEL maintainer="Rishi Ghan " -# Working directory +# Set the working directory WORKDIR /metadata-service -# Install dependencies + +# Copy and install dependencies COPY package.json package-lock.json ./ RUN npm ci --silent -# Copy source +# Copy source code and build the application COPY . . +RUN npm run build -# Build and cleanup +# Clean up development dependencies +RUN npm prune --production + +# Final image using Node 21 +FROM node:21-alpine + +LABEL maintainer="Rishi Ghan " + +# Set the working directory +WORKDIR /metadata-service + +# Copy the necessary files from the builder image +COPY --from=builder /metadata-service /metadata-service + +# Set environment variables ENV NODE_ENV=production -RUN npm run build \ - && npm prune +# Expose the application's port EXPOSE 3080 -# Start server -CMD ["npm", "start"] \ No newline at end of file + +# Start the application +CMD ["npm", "start"]