41 lines
938 B
Docker
41 lines
938 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
|
|
|
|
# Define the build-time argument
|
|
ARG REACT_APP_BACKEND_URL
|
|
# Set the environment variable for the build process
|
|
ENV REACT_APP_BACKEND_URL=$REACT_APP_BACKEND_URL
|
|
|
|
# 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"]
|