36 lines
776 B
Docker
36 lines
776 B
Docker
# Use an official Node.js runtime as a parent image for building
|
|
FROM node:18-alpine as builder
|
|
|
|
# Set the working directory in the container
|
|
WORKDIR /usr/src/app
|
|
|
|
# Copy package.json and package-lock.json to the working directory
|
|
COPY package*.json ./
|
|
|
|
# Install any needed packages
|
|
RUN npm install
|
|
|
|
# Bundle app source
|
|
COPY . .
|
|
|
|
# Build the app
|
|
RUN npm run build
|
|
|
|
# Use a lightweight web server to serve the static files
|
|
FROM node:18-alpine
|
|
|
|
# Set the working directory
|
|
WORKDIR /usr/src/app
|
|
|
|
# Copy the build output from the builder stage
|
|
COPY --from=builder /usr/src/app/build .
|
|
|
|
# Install serve
|
|
RUN npm install -g serve
|
|
|
|
# Make port 3000 available to the world outside this container
|
|
EXPOSE 3000
|
|
|
|
# Define the command to run the app
|
|
CMD ["serve", "-s", ".", "-l", "3000"]
|