docker fix

This commit is contained in:
dimitar committed 2026-02-23 05:18:40 +01:00
1 parent dc93a8b652
commit cfc43a7119
3 files changed
+9 -26

No files matched your search

+9 -12
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"]