zauberkiste/dockerfile

51 lines
1 KiB
Text

# Stage 1: Base stage
FROM node:18 AS base
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application files
COPY . .
# Define build arguments
ARG NODE_ENV
ENV NODE_ENV=$NODE_ENV
# Stage 2: Development stage
FROM base AS dev
# Expose ports needed for the development server and hot module reloading
EXPOSE 5173 24678
# In development mode, run the dev server
CMD ["npm", "run", "dev", "--", "--host"]
# Stage 3: Build for production
FROM base AS build
# Build the Svelte app in production mode
RUN npm run build
# Stage 4: Production stage
FROM node:18-alpine AS prod
# Install a lightweight server to serve the production build
RUN npm install -g serve
# Set the working directory
WORKDIR /app
# Copy the built files from the build stage
COPY --from=build /app/build /app/build
# Expose port 5000 for serving the production app
EXPOSE 5000
# Serve the production build
CMD ["serve", "-s", "build", "-l", "5000"]