docker fix

This commit is contained in:
echo 2026-02-23 05:18:40 +01:00
parent dc93a8b652
commit cfc43a7119
3 changed files with 9 additions and 26 deletions

View File

@ -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"]
CMD ["npm", "run", "start"]

View File

@ -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

View File

@ -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