mirror of
https://github.com/R0m1k3/podcastic.git
synced 2026-10-11 17:26:20 +02:00
simplify: use official Docker images with clean docker-compose.yml - no complex Dockerfile needed
This commit is contained in:
1 parent
65d43c3afb
commit
547de27eed
4 files changed
+31
-219
No files matched your search
@@ -5,7 +5,8 @@
|
||||
"Bash(rtk npm:*)",
|
||||
"Bash(git remote:*)",
|
||||
"Bash(git branch:*)",
|
||||
"Bash(git push:*)"
|
||||
"Bash(git push:*)",
|
||||
"Bash(ls -la /c/Claude/Podcastic/Dockerfile*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
# Multi-stage build for Podcastic All-in-One Container
|
||||
# Combines: Backend (Node.js), Frontend (React), Web Server (Nginx), Database (MongoDB), Cache (Redis)
|
||||
|
||||
# ==================== STAGE 1: Build Backend ====================
|
||||
FROM node:20-alpine AS backend-builder
|
||||
|
||||
WORKDIR /build/backend
|
||||
|
||||
COPY backend/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY backend/tsconfig.json ./
|
||||
COPY backend/src ./src
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# ==================== STAGE 2: Build Frontend ====================
|
||||
FROM node:20-alpine AS frontend-builder
|
||||
|
||||
WORKDIR /build/frontend
|
||||
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY frontend/tsconfig*.json ./
|
||||
COPY frontend/vite.config.ts ./
|
||||
COPY frontend/postcss.config.js ./
|
||||
COPY frontend/tailwind.config.js ./
|
||||
COPY frontend/index.html ./
|
||||
COPY frontend/src ./src
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# ==================== STAGE 3: Final Image ====================
|
||||
FROM node:20-alpine
|
||||
|
||||
# Install supervisor to manage multiple processes, mongodb, redis, nginx
|
||||
RUN apk add --no-cache supervisor nginx mongodb redis bash curl
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# ==================== Setup Backend ====================
|
||||
COPY --from=backend-builder /build/backend/dist ./backend/dist
|
||||
COPY --from=backend-builder /build/backend/package*.json ./backend/
|
||||
RUN cd backend && npm ci --only=production
|
||||
|
||||
# ==================== Setup Frontend ====================
|
||||
RUN mkdir -p /usr/share/nginx/html
|
||||
COPY --from=frontend-builder /build/frontend/dist/* /usr/share/nginx/html/
|
||||
|
||||
# ==================== Setup Nginx ====================
|
||||
RUN mkdir -p /etc/nginx/conf.d
|
||||
|
||||
COPY <<'EOF' /etc/nginx/conf.d/default.conf
|
||||
server {
|
||||
listen 3579;
|
||||
server_name _;
|
||||
client_max_body_size 100M;
|
||||
|
||||
# Frontend - Static files
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
expires 1d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Static assets with long cache
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
root /usr/share/nginx/html;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# API - Proxy to backend
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:5000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# Health check endpoint
|
||||
location /health {
|
||||
proxy_pass http://127.0.0.1:5000;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# ==================== Setup Supervisor ====================
|
||||
RUN mkdir -p /var/log/supervisor
|
||||
|
||||
COPY <<'EOF' /etc/supervisor/conf.d/supervisord.conf
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
|
||||
[program:mongodb]
|
||||
command=/usr/bin/mongod --dbpath /data/db --bind_ip 127.0.0.1
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/supervisor/mongodb.err.log
|
||||
stdout_logfile=/var/log/supervisor/mongodb.out.log
|
||||
|
||||
[program:redis]
|
||||
command=/usr/bin/redis-server --bind 127.0.0.1
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/supervisor/redis.err.log
|
||||
stdout_logfile=/var/log/supervisor/redis.out.log
|
||||
|
||||
[program:backend]
|
||||
command=/bin/bash -c "cd /app/backend && node dist/index.js"
|
||||
environment=NODE_ENV=production,MONGODB_URI=mongodb://127.0.0.1:27017/podcastic,REDIS_URL=redis://127.0.0.1:6379
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/supervisor/backend.err.log
|
||||
stdout_logfile=/var/log/supervisor/backend.out.log
|
||||
|
||||
[program:nginx]
|
||||
command=/usr/sbin/nginx -g "daemon off;"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/supervisor/nginx.err.log
|
||||
stdout_logfile=/var/log/supervisor/nginx.out.log
|
||||
EOF
|
||||
|
||||
# ==================== Create Data Directories ====================
|
||||
RUN mkdir -p /data/db /data/redis
|
||||
|
||||
# ==================== Environment ====================
|
||||
ENV NODE_ENV=production
|
||||
ENV MONGODB_URI=mongodb://127.0.0.1:27017/podcastic
|
||||
ENV REDIS_URL=redis://127.0.0.1:6379
|
||||
ENV PORT=5000
|
||||
|
||||
# ==================== Health Check ====================
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD curl -f http://127.0.0.1:3579/health || exit 1
|
||||
|
||||
# ==================== Expose Port ====================
|
||||
EXPOSE 3579
|
||||
|
||||
# ==================== Entrypoint ====================
|
||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||
@@ -1,30 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
podcastic:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.unraid
|
||||
container_name: podcastic
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3579:3579"
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 5000
|
||||
MONGODB_URI: mongodb://127.0.0.1:27017/podcastic
|
||||
REDIS_URL: redis://127.0.0.1:6379
|
||||
JWT_SECRET: ${JWT_SECRET:-change_me_in_production}
|
||||
JWT_EXPIRES_IN: 7d
|
||||
JWT_REFRESH_EXPIRES_IN: 30d
|
||||
PODCAST_INDEX_API_KEY: ${PODCAST_INDEX_API_KEY:-}
|
||||
PODCAST_INDEX_API_SECRET: ${PODCAST_INDEX_API_SECRET:-}
|
||||
volumes:
|
||||
- podcastic_db:/data/db
|
||||
- podcastic_redis:/data/redis
|
||||
- podcastic_logs:/var/log/supervisor
|
||||
|
||||
volumes:
|
||||
podcastic_db:
|
||||
podcastic_redis:
|
||||
podcastic_logs:
|
||||
+29
-34
@@ -1,20 +1,16 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
mongo:
|
||||
mongodb:
|
||||
image: mongo:latest
|
||||
container_name: podcastic-mongo
|
||||
container_name: podcastic-mongodb
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "27017:27017"
|
||||
environment:
|
||||
MONGO_INITDB_DATABASE: podcastic
|
||||
MONGO_INITDB_ROOT_USERNAME: podcastic
|
||||
MONGO_INITDB_ROOT_PASSWORD: podcastic_dev
|
||||
volumes:
|
||||
- mongo_data:/data/db
|
||||
- mongodb_data:/data/db
|
||||
networks:
|
||||
- podcastic-network
|
||||
- podcastic
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
@@ -22,58 +18,57 @@ services:
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "6379:6379"
|
||||
command: redis-server --appendonly yes
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
networks:
|
||||
- podcastic-network
|
||||
- podcastic
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
image: node:20-alpine
|
||||
container_name: podcastic-backend
|
||||
restart: unless-stopped
|
||||
working_dir: /app
|
||||
ports:
|
||||
- "5000:5000"
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
MONGODB_URI: mongodb://podcastic:podcastic_dev@mongo:27017/podcastic
|
||||
NODE_ENV: production
|
||||
MONGODB_URI: mongodb://mongodb:27017/podcastic
|
||||
REDIS_URL: redis://redis:6379
|
||||
JWT_SECRET: dev_secret_key_change_in_prod
|
||||
depends_on:
|
||||
- mongo
|
||||
- redis
|
||||
JWT_SECRET: ${JWT_SECRET:-change_me_in_production}
|
||||
JWT_EXPIRES_IN: 7d
|
||||
JWT_REFRESH_EXPIRES_IN: 30d
|
||||
PODCAST_INDEX_API_KEY: ${PODCAST_INDEX_API_KEY:-}
|
||||
PODCAST_INDEX_API_SECRET: ${PODCAST_INDEX_API_SECRET:-}
|
||||
volumes:
|
||||
- ./backend/src:/app/src
|
||||
- /app/node_modules
|
||||
- ./backend:/app
|
||||
command: sh -c "npm install && npm run build && node dist/index.js"
|
||||
depends_on:
|
||||
- mongodb
|
||||
- redis
|
||||
networks:
|
||||
- podcastic-network
|
||||
command: npm run dev
|
||||
- podcastic
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
image: node:20-alpine
|
||||
container_name: podcastic-frontend
|
||||
restart: unless-stopped
|
||||
working_dir: /app
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "3579:3579"
|
||||
environment:
|
||||
VITE_API_URL: http://localhost:5000/api
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
command: sh -c "npm install && npm run build && npm install -g serve && serve -s dist -l 3579"
|
||||
depends_on:
|
||||
- backend
|
||||
volumes:
|
||||
- ./frontend/src:/app/src
|
||||
- /app/node_modules
|
||||
networks:
|
||||
- podcastic-network
|
||||
command: npm run dev
|
||||
- podcastic
|
||||
|
||||
volumes:
|
||||
mongo_data:
|
||||
mongodb_data:
|
||||
redis_data:
|
||||
|
||||
networks:
|
||||
podcastic-network:
|
||||
podcastic:
|
||||
driver: bridge
|
||||
Reference in new issue
Block a user