mirror of
https://github.com/xlorepdarkhelm/numinar-coding-project.git
synced 2026-09-06 05:28:25 -04:00
47 lines
1.2 KiB
Docker
47 lines
1.2 KiB
Docker
# Build stage
|
|
FROM node:24.6.0 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 node:24.6.0-slim
|
|
|
|
# Setting working directory for build
|
|
WORKDIR /app
|
|
|
|
# Installing serve to run the production build
|
|
RUN yarn global add serve
|
|
|
|
# Copying only the necessary files from the builder stage
|
|
# This includes package.json, yarn.lock, tsconfig.json, node_modules, public, and the build output
|
|
COPY --from=builder /app/package*.json ./
|
|
COPY --from=builder /app/yarn.lock ./
|
|
COPY --from=builder /app/tsconfig.json ./
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/public ./public
|
|
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"] |