Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.git
.gitignore
README.md
.dockerignore
docker-compose.prod.yml
node_modules
npm-debug.log
*.log
.env
.env.local
.docs
.husky
scripts/
public/
docs/
24 changes: 14 additions & 10 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Use Node.js 18 as the base image to match pnpm requirements
# Use Node.js 18 as the base image
FROM node:18-alpine

# Set working directory
Expand All @@ -7,24 +7,28 @@ WORKDIR /app
# Install pnpm globally
RUN npm install -g pnpm

# Copy package files
COPY package.json ./
# Copy ALL files from the project root
COPY . .

# Install dependencies
RUN pnpm install --frozen-lockfile
# Debug: Show what files were copied
RUN echo "=== Files in /app ===" && ls -la
RUN echo "=== pnpm-lock.yaml exists? ===" && test -f pnpm-lock.yaml && echo "YES" || echo "NO"
RUN echo "=== pnpm-workspace.yaml exists? ===" && test -f pnpm-workspace.yaml && echo "YES" || echo "NO"
RUN echo "=== client/package.json exists? ===" && test -f client/package.json && echo "YES" || echo "NO"

# Copy source code
COPY . .
# Install dependencies - ALWAYS use --no-frozen-lockfile to avoid issues
RUN pnpm install --no-frozen-lockfile

# Build the application
# Build the client application
WORKDIR /app/client
RUN pnpm run build

# Expose port
EXPOSE 3001

# Create a non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001

# Change ownership of the app directory
RUN chown -R nextjs:nodejs /app
Expand Down
34 changes: 22 additions & 12 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: '3.8'

services:
db:
image: mysql:5.7
container_name: reactpress_db
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
Expand All @@ -11,44 +10,55 @@ services:
MYSQL_PASSWORD: ${DB_PASSWD:-reactpress}
volumes:
- db_data:/var/lib/mysql
networks:
- reactpress-network

server:
build:
context: ./server
dockerfile: Dockerfile
context: .
dockerfile: server/Dockerfile
container_name: reactpress_server
restart: always
depends_on:
- db
environment:
- NODE_ENV=production
- DB_HOST=${DB_HOST:-db}
- DB_PORT=${DB_PORT:-3306}
- DB_USER=${DB_USER:-reactpress}
- DB_PASSWD=${DB_PASSWD:-reactpress}
- DB_DATABASE=${DB_DATABASE:-reactpress}
- CLIENT_SITE_URL=${CLIENT_SITE_URL:-http://localhost:3001}
- SERVER_SITE_URL=${SERVER_SITE_URL:-http://localhost:3002}
networks:
- reactpress-network

client:
build:
context: ./client
dockerfile: Dockerfile
context: .
dockerfile: client/Dockerfile
container_name: reactpress_client
restart: always
depends_on:
- server
environment:
- CLIENT_SITE_URL=${CLIENT_SITE_URL:-http://localhost:3001}
- SERVER_SITE_URL=${SERVER_SITE_URL:-http://localhost:3002}
- NODE_ENV=production
networks:
- reactpress-network

nginx:
image: nginx:alpine
container_name: reactpress_nginx
ports:
- "8080:80"
depends_on:
- client
- server
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
networks:
- reactpress-network

volumes:
db_data:
db_data:

networks:
reactpress-network:
driver: bridge
Loading