Spaces:
Build error
Build error
File size: 1,350 Bytes
19385bc 65c09e3 19385bc 65c09e3 19385bc 65c09e3 19385bc 65c09e3 19385bc 65c09e3 19385bc |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# Build stage
FROM node:18-alpine AS build
# Set build arguments
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm ci --no-audit --no-fund
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node:18-alpine
WORKDIR /app
# Install wget for health check and other utilities
RUN apk --no-cache add wget curl
# Create a non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Copy only production dependencies
COPY package*.json ./
RUN npm ci --only=production --no-audit --no-fund
# Copy built application from build stage
COPY --from=build /app/dist ./dist
COPY --from=build /app/server.cjs ./
COPY --from=build /app/api ./api
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3001
# Create a directory for environment files
RUN mkdir -p /app/config
# Note: Environment variables should be passed at runtime
# Example: docker run -e GEMINI_API_KEY=your_key -e DATABASE_URL=your_url ...
# Expose the port
EXPOSE 3001
# Add health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3001/health || exit 1
# Switch to non-root user
USER appuser
# Start the server
CMD ["node", "server.cjs"] |