Simple example of react dev container
This commit is contained in:
36
examples/react-app/Dockerfile
Normal file
36
examples/react-app/Dockerfile
Normal file
@ -0,0 +1,36 @@
|
||||
# Stage 1 - Define Base image
|
||||
FROM node:22-alpine AS base
|
||||
|
||||
# Stage 2 Install dependencies
|
||||
FROM base AS install-deps
|
||||
# Set working directory inside the build container
|
||||
WORKDIR /app
|
||||
COPY package*.json /app/
|
||||
RUN yarn
|
||||
|
||||
FROM install-deps AS develop
|
||||
WORKDIR /app
|
||||
COPY --from=install-deps /app/node_modules /app/node_modules
|
||||
COPY . .
|
||||
ENTRYPOINT ["yarn", "dev", "--host=0.0.0.0"]
|
||||
EXPOSE 5173
|
||||
|
||||
FROM base AS build
|
||||
WORKDIR /app
|
||||
COPY package*.json /app/
|
||||
RUN yarn install --frozen-lockfile
|
||||
COPY . .
|
||||
RUN yarn build
|
||||
|
||||
FROM nginx:alpine AS production
|
||||
RUN apk add curl && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
COPY --from=build /app/dist /usr/share/nginx/html/
|
||||
EXPOSE 80
|
||||
ENTRYPOINT [ "nginx", "-g", "daemon off;" ]
|
||||
HEALTHCHECK --interval=5s \
|
||||
--timeout=5s \
|
||||
--start-period=5s \
|
||||
--retries=3 \
|
||||
CMD "/usr/bin/curl localhost" || exit 1
|
Reference in New Issue
Block a user