Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Last active October 22, 2023 19:44
Show Gist options
  • Select an option

  • Save diegofcornejo/589cb06bce3b11555fb72d0b1cf17034 to your computer and use it in GitHub Desktop.

Select an option

Save diegofcornejo/589cb06bce3b11555fb72d0b1cf17034 to your computer and use it in GitHub Desktop.
Dockerize: Build (Vite) React App inside Turborepo and serve on nginx
# Build stage
from node:18-alpine3.17 as build
WORKDIR /app
# Copy whole project
COPY ../../ .
# Install dependencies
RUN yarn install
# Change working directory to myapp app
# WORKDIR /app/apps/myapp
# Build app
RUN yarn workspace myapp build
# Check if build was successful
# RUN ls /app/apps/myapp/
# Production stage
FROM nginx:stable-alpine-slim as production
# Copy build artifacts from build stage
COPY --from=build /app/apps/myapp/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment