Publish Fast Tabler Docker image / build-and-push-fast (push) Failing after 6m38s
47 lines
1.2 KiB
Docker
47 lines
1.2 KiB
Docker
# Stage 1: Build React frontend
|
|
FROM node:20-alpine AS frontend-builder
|
|
WORKDIR /app/frontend
|
|
|
|
# Set npm config for better performance
|
|
RUN npm config set registry https://registry.npmjs.org/
|
|
RUN npm config set fetch-timeout 300000
|
|
RUN npm config set fetch-retry-mintimeout 20000
|
|
RUN npm config set fetch-retry-maxtimeout 120000
|
|
|
|
# Copy package files first for better caching
|
|
COPY frontend/package*.json ./
|
|
|
|
# Install dependencies with specific flags for speed
|
|
RUN npm ci --no-audit --no-fund --prefer-offline
|
|
|
|
# Copy source code
|
|
COPY frontend/ .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Stage 2: Setup Node.js backend and serve everything
|
|
FROM node:20-alpine
|
|
WORKDIR /app
|
|
|
|
# Set npm config for better performance
|
|
RUN npm config set registry https://registry.npmjs.org/
|
|
RUN npm config set fetch-timeout 300000
|
|
|
|
# Copy package files first for better caching
|
|
COPY backend/package*.json ./
|
|
|
|
# Install production dependencies only
|
|
RUN npm ci --only=production --no-audit --no-fund --prefer-offline
|
|
|
|
# Copy backend source code
|
|
COPY backend/ .
|
|
|
|
# Copy built frontend assets from the previous stage
|
|
COPY --from=frontend-builder /app/frontend/dist ./public
|
|
|
|
# The port the backend runs on
|
|
EXPOSE 3001
|
|
|
|
# Start the server
|
|
CMD ["node", "server.js"] |