Fix Docker build - add React build step back to Dockerfile
The build/ directory doesn't exist in Docker context, so we need to build the React app inside the container. This approach: - Installs all deps, builds app, then removes dev deps - Works for remote deployments without requiring pre-built artifacts - Maintains lean final image size
This commit is contained in:
15
Dockerfile
15
Dockerfile
@@ -7,14 +7,19 @@ WORKDIR /app
|
|||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install dependencies (production only)
|
# Install dependencies (production + dev for build)
|
||||||
RUN npm ci --only=production
|
RUN npm ci
|
||||||
|
|
||||||
# Copy server code
|
# Copy source code
|
||||||
|
COPY src/ ./src/
|
||||||
|
COPY public/ ./public/
|
||||||
COPY server.js ./server.js
|
COPY server.js ./server.js
|
||||||
|
|
||||||
# Copy built application
|
# Build the application
|
||||||
COPY build/ ./build/
|
RUN npm run build
|
||||||
|
|
||||||
|
# Remove dev dependencies to reduce image size
|
||||||
|
RUN npm ci --only=production && npm cache clean --force
|
||||||
|
|
||||||
# Expose port 3000
|
# Expose port 3000
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
Reference in New Issue
Block a user