diff --git a/cms/cms/Dockerfile b/cms/cms/Dockerfile index c3d2ba7..599b0c5 100644 --- a/cms/cms/Dockerfile +++ b/cms/cms/Dockerfile @@ -9,8 +9,8 @@ WORKDIR /app COPY package*.json ./ COPY package-lock.json* ./ -# Install dependencies -RUN npm ci --only=production +# Install ALL dependencies (need devDependencies for build) +RUN npm ci # Copy source code COPY . . @@ -18,6 +18,9 @@ COPY . . # Build Strapi RUN npm run build +# Prune devDependencies after build +RUN npm prune --production + # Production stage FROM node:20-alpine @@ -27,19 +30,13 @@ WORKDIR /app RUN addgroup -g 1001 -S nodejs && \ adduser -S nodejs -u 1001 -# Install SQLite for development (will use PostgreSQL in production) -RUN apk add --no-cache sqlite - # Copy built application from builder stage COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist COPY --from=builder --chown=nodejs:nodejs /app/public ./public COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules COPY --from=builder --chown=nodejs:nodejs /app/package*.json ./ -# Copy environment configuration -COPY --chown=nodejs:nodejs .env.example .env - -# Create data directory for SQLite +# Create data directory RUN mkdir -p /app/.tmp && \ chown -R nodejs:nodejs /app/.tmp @@ -47,11 +44,11 @@ RUN mkdir -p /app/.tmp && \ USER nodejs # Health check -HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD node -e "require('http').get('http://localhost:1337/_health', (r) => {if(r.statusCode !== 200) throw new Error()})" +HEALTHCHECK --interval=30s --timeout=3s --start-period=60s --retries=3 \ + CMD node -e "require('http').get('http://localhost:1337/_health', (r) => {if(r.statusCode !== 200) process.exit(1)})" # Expose port EXPOSE 1337 # Start Strapi -CMD ["npm", "run", "start"] \ No newline at end of file +CMD ["npm", "run", "start"] diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 9edffcb..58ac100 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -29,19 +29,12 @@ RUN npm run build # Production stage FROM nginx:alpine -# Create non-root user -RUN addgroup -g 1001 -S nginx && \ - adduser -S nginx -u 1001 -G nginx - # Copy built application from builder stage COPY --from=builder --chown=nginx:nginx /app/dist /usr/share/nginx/html # Copy nginx configuration COPY nginx.conf /etc/nginx/nginx.conf -# Switch to non-root user -USER nginx - # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1 diff --git a/pwa/Dockerfile b/pwa/Dockerfile index 3289378..8301629 100644 --- a/pwa/Dockerfile +++ b/pwa/Dockerfile @@ -29,19 +29,12 @@ RUN npm run build # Production stage FROM nginx:alpine -# Create non-root user -RUN addgroup -g 1001 -S nginx && \ - adduser -S nginx -u 1001 -G nginx - # Copy built application from builder stage COPY --from=builder --chown=nginx:nginx /app/dist /usr/share/nginx/html # Copy nginx configuration COPY nginx.conf /etc/nginx/nginx.conf -# Switch to non-root user -USER nginx - # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1