Files
conference-room-booking-system/frontend/Dockerfile

46 lines
1006 B
Docker

FROM node:24.6.0-slim AS base
# Installing npm globally to ensure the latest version is used
RUN npm install --location=global npm@latest
# Build stage
FROM base AS builder
# Setting working directory for build
WORKDIR /app
# Copying package.json and package-lock.json to leverage Docker cache
COPY package*.json ./
# Copying TypeScript configuration
COPY tsconfig.json ./
# Copying yarn configuration files
COPY yarn.lock ./
# Installing dependencies
RUN yarn install --frozen-lockfile
# Copying the rest of the application code
COPY . .
# Building the TypeScript React app for production
RUN yarn run build
# Production stage
FROM base
# Setting working directory
WORKDIR /app
# Installing serve to run the production build
RUN yarn global add serve
# Copying only the build output from the builder stage
COPY --from=builder /app/build ./build
# Exposing the port the app will run on
EXPOSE 3000
# Starting the server to serve the built React app
CMD ["serve", "-s", "build", "-l", "3000"]