29 lines
575 B
Docker
29 lines
575 B
Docker
# Assuming your app runs `vite build`
|
|
ARG VITE_API_URL
|
|
ENV VITE_API_URL=$VITE_API_URL
|
|
|
|
# Stage 1: Build the Vite React app
|
|
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies
|
|
COPY package.json /app
|
|
COPY yarn.lock /app
|
|
RUN yarn install
|
|
|
|
COPY . .
|
|
RUN yarn build
|
|
|
|
# Stage 2: Serve with Caddy
|
|
FROM caddy:alpine
|
|
|
|
# Copy built app to the web root
|
|
COPY --from=builder /app/dist /usr/share/caddy
|
|
|
|
# Add Caddyfile (for routing support)
|
|
COPY Caddyfile /etc/caddy/Caddyfile
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
|