forked from sudeepmahato16/movie-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (30 loc) · 1.47 KB
/
Copy pathDockerfile
File metadata and controls
41 lines (30 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# ─────────────────────────────────────────────
# Stage 1: build
# ─────────────────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /app
# Install deps first (layer-cached unless package.json changes)
COPY package*.json ./
RUN npm ci --frozen-lockfile
# Pass TMDB key at build time (Vite bakes it into the bundle)
ARG VITE_API_KEY
ENV VITE_API_KEY=$VITE_API_KEY
ARG VITE_TMDB_API_BASE_URL=https://api.themoviedb.org/3
ENV VITE_TMDB_API_BASE_URL=$VITE_TMDB_API_BASE_URL
COPY . .
RUN npm run build
# ─────────────────────────────────────────────
# Stage 2: serve with nginx (no Node runtime)
# ─────────────────────────────────────────────
FROM nginx:1.27-alpine
# Remove default nginx config
RUN rm /etc/nginx/conf.d/default.conf
# Copy our custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built React app from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# nginx runs as root by default; expose port 80
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost:80/ || exit 1
CMD ["nginx", "-g", "daemon off;"]