docker implementation
This commit is contained in:
1 parent
7c7bb45446
commit
0c2433cac6
26 files changed
+2200
-13
No files matched your search
@@ -0,0 +1,57 @@
|
||||
# CMS Dockerfile for Placebo.mk Strapi CMS
|
||||
|
||||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
COPY package-lock.json* ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build Strapi
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Create non-root user
|
||||
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
|
||||
RUN mkdir -p /app/.tmp && \
|
||||
chown -R nodejs:nodejs /app/.tmp
|
||||
|
||||
# Switch to non-root user
|
||||
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()})"
|
||||
|
||||
# Expose port
|
||||
EXPOSE 1337
|
||||
|
||||
# Start Strapi
|
||||
CMD ["npm", "run", "start"]
|
||||
@@ -0,0 +1,35 @@
|
||||
# CMS Development Dockerfile for Placebo.mk Strapi CMS
|
||||
|
||||
FROM node:20-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install Python and build tools for any native modules
|
||||
RUN apt-get update && apt-get install -y \
|
||||
python3 \
|
||||
make \
|
||||
g++ \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install dependencies with better error handling
|
||||
COPY package*.json ./
|
||||
COPY package-lock.json* ./
|
||||
|
||||
# Fix permissions before npm install
|
||||
RUN chown -R node:node /app
|
||||
|
||||
# Switch to non-root user for npm install
|
||||
USER node
|
||||
|
||||
# Clear npm cache and install dependencies
|
||||
RUN npm cache clean --force && \
|
||||
npm install
|
||||
|
||||
# Copy source code as node user
|
||||
COPY --chown=node:node . .
|
||||
|
||||
# Expose port
|
||||
EXPOSE 1337
|
||||
|
||||
# Start development server
|
||||
CMD ["npm", "run", "develop"]
|
||||
@@ -18,7 +18,7 @@
|
||||
"@strapi/plugin-cloud": "5.33.0",
|
||||
"@strapi/plugin-users-permissions": "5.33.0",
|
||||
"@strapi/strapi": "5.33.0",
|
||||
"better-sqlite3": "12.4.1",
|
||||
"pg": "^8.13.3",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"react-router-dom": "^6.0.0",
|
||||
|
||||
Reference in new issue
Block a user