56 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
# Multi-stage build for optimized image size
 | 
						|
FROM oven/bun:latest AS builder
 | 
						|
 | 
						|
WORKDIR /app
 | 
						|
 | 
						|
# Copy package files first for better caching
 | 
						|
COPY package.json bun.lock ./
 | 
						|
COPY admin-panel/package.json ./admin-panel/
 | 
						|
# COPY frontend/package.json ./frontend/
 | 
						|
 | 
						|
# Install dependencies
 | 
						|
RUN bun install && cd admin-panel && bun install && cd ..
 | 
						|
 | 
						|
# Copy source files
 | 
						|
COPY . .
 | 
						|
 | 
						|
# Build frontend and admin panel
 | 
						|
RUN bun run build:frontend && bun run build:admin
 | 
						|
 | 
						|
# Production stage
 | 
						|
FROM oven/bun:latest AS runtime
 | 
						|
 | 
						|
WORKDIR /app
 | 
						|
 | 
						|
# Install MeCab for English to Katakana conversion and Chrome dependencies for Puppeteer
 | 
						|
RUN apt-get update && \
 | 
						|
    apt-get install -y \
 | 
						|
        mecab mecab-ipadic-utf8 libmecab-dev \
 | 
						|
        wget gnupg ca-certificates \
 | 
						|
        fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \
 | 
						|
        libdrm2 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libxss1 \
 | 
						|
        libgtk-3-0 libnspr4 libnss3 libxdamage1 libxfixes3 libxrandr2 \
 | 
						|
        libgconf-2-4 libxss1 libasound2 libxtst6 libatspi2.0-0 libdrm2 \
 | 
						|
        libxcomposite1 libxcursor1 libxi6 libxtst6 xdg-utils lsb-release \
 | 
						|
        libglib2.0-0 libnss3-dev libgconf-2-4 libxrandr2 libasound2-dev \
 | 
						|
        libpangocairo-1.0-0 libatk1.0-dev libcairo-gobject2 libgtk-3-dev \
 | 
						|
        libgdk-pixbuf2.0-dev \
 | 
						|
        --no-install-recommends && \
 | 
						|
    apt-get clean && \
 | 
						|
    rm -rf /var/lib/apt/lists/*
 | 
						|
 | 
						|
RUN bunx puppeteer browsers install chrome
 | 
						|
 | 
						|
# Copy built application from builder stage
 | 
						|
COPY --from=builder /app .
 | 
						|
 | 
						|
# Expose ports
 | 
						|
EXPOSE 3000 3001
 | 
						|
 | 
						|
# Health check
 | 
						|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
 | 
						|
    CMD bun -e "fetch('http://localhost:3000').then(() => process.exit(0)).catch(() => process.exit(1))"
 | 
						|
 | 
						|
# Start both servers with proper process management
 | 
						|
CMD ["sh", "-c", "bun run /app/server.ts & (sleep 10 && bun run /app/admin-server.ts) & wait"]
 |