Bang/docker/Dockerfile

33 lines
681 B
Docker
Raw Normal View History

2025-02-27 11:44:25 -06:00
# Stage 1: Build the project
2025-02-27 12:28:50 -06:00
FROM node:18 AS builder
2025-02-27 11:44:25 -06:00
WORKDIR /app
2025-02-27 12:28:50 -06:00
# Copy package.json and pnpm-lock.yaml to the working directory
COPY package.json pnpm-lock.yaml ./
2025-02-27 11:44:25 -06:00
# Install dependencies
RUN npm install -g pnpm
RUN pnpm install
# Copy project files into the docker image
2025-02-27 12:28:50 -06:00
COPY . .
2025-02-27 11:44:25 -06:00
# Build the project
RUN pnpm run build
2025-02-27 12:28:50 -06:00
# Stage 2: Serve the app using the same version of Node
FROM node:18-alpine
WORKDIR /app
2025-02-27 11:44:25 -06:00
# Install a simple http server
RUN npm install -g serve
# Copy built assets from the builder stage
2025-02-27 12:28:50 -06:00
COPY --from=builder /app/dist ./
2025-02-27 11:44:25 -06:00
# Expose port 5000 for the server
EXPOSE 5000
# Start the server using the `serve` package
CMD ["serve", "-s", ".", "-l", "5000"]