update Docker deployment

This commit is contained in:
TheMaddax 2025-05-27 12:45:16 -05:00
parent b6f727be5d
commit 3e1892a6f7
5 changed files with 48 additions and 94 deletions

View file

@ -2,9 +2,6 @@ FROM node:20-alpine AS base
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
# Create required directories
RUN mkdir -p public/images/thumbnails public/subtitles public/transcriptions
# Copy package files first
COPY package.json pnpm-lock.yaml ./
@ -16,16 +13,6 @@ RUN pnpm install --frozen-lockfile
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Verification steps with output to file
RUN echo "=== BUILDER STAGE: Verifying source files ===" > /verification.txt && \
echo "Contents of /app/public:" >> /verification.txt && \
ls -la /app/public >> /verification.txt && \
echo "\nContents of /app/public/images:" >> /verification.txt && \
ls -la /app/public/images >> /verification.txt && \
echo "\nContents of /app/public/images/thumbnails:" >> /verification.txt && \
ls -la /app/public/images/thumbnails >> /verification.txt && \
echo "\nAll files under public:" >> /verification.txt && \
find /app/public -type f >> /verification.txt
RUN pnpm build
# Production image
@ -37,28 +24,14 @@ RUN mkdir -p /usr/share/nginx/html/images/thumbnails \
/usr/share/nginx/html/transcriptions \
/usr/share/nginx/html/videos
# Copy verification file from builder
COPY --from=builder /verification.txt /verification.txt
# Copy built app and static assets
COPY --from=builder /app/dist /usr/share/nginx/html
COPY --from=builder /app/public/images/ /usr/share/nginx/html/images/
COPY --from=builder /app/public/subtitles /usr/share/nginx/html/subtitles
COPY --from=builder /app/public/transcriptions /usr/share/nginx/html/transcriptions
# Copy configurations
COPY nginx.conf /etc/nginx/nginx.conf
COPY matomo_log_format.conf /etc/nginx/conf.d/
COPY default.conf /etc/nginx/conf.d/
# Add runner stage verification to the file
RUN echo "\n=== RUNNER STAGE: Verifying nginx html directory structure ===" >> /verification.txt && \
echo "Contents of /usr/share/nginx/html:" >> /verification.txt && \
ls -la /usr/share/nginx/html >> /verification.txt && \
echo "\nContents of /usr/share/nginx/html/images:" >> /verification.txt && \
ls -la /usr/share/nginx/html/images >> /verification.txt && \
echo "\nAll files under html:" >> /verification.txt && \
find /usr/share/nginx/html -type f >> /verification.txt
# Copy nginx configuration
COPY default.conf /etc/nginx/conf.d/default.conf
EXPOSE 804

View file

@ -1,8 +1,30 @@
# Active Context - Current Work Status
## Recently Completed Work
## Recently Completed Work
**Date: 5/27/2025**
### ✅ Docker Production Configuration - COMPLETED
Successfully configured Docker setup for production deployment behind Caddy reverse proxy:
**Key Changes Made:**
- **Server Analysis**: SSH'd to production server (10.4.0.206) to verify compatibility
- **Network Integration**: Configured containers for `caddy_network` (172.22.0.0/16)
- **Container Naming**: Set proper container names to match Caddy expectations:
- `deafgain-website-web-1` (port 804)
- `deafgain-website-api-1` (port 3000)
- `deafgain-website-redis-1`
- **Volume Mounting**: Added video content volume mapping `/docker/websites/deafgain/video_content:/usr/share/nginx/html/videos`
- **API Routing**: Updated nginx config for `/api/contact` and `/api/subscribe` endpoints
- **Frontend Updates**: Modified Resources.tsx to use `/api/subscribe` endpoint
**Files Updated:**
- `Dockerfile` - Cleaned up and optimized for production
- `docker-compose.yml` - Added external caddy_network, proper container names, volume mounts
- `default.conf` - Fixed nginx routing for API and video serving
- `src/pages/Resources.tsx` - Updated API endpoints
**Production Ready Status:** ✅ All configurations verified compatible with existing server infrastructure
### ✅ Governance Documents Video Integration - COMPLETED
Successfully added the new "Governance Documents: Understanding the Hierarchy" video to the DeafGain website:

View file

@ -1,42 +1,28 @@
server {
listen 804;
server_name localhost;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Updated log settings with smaller buffer and faster flush
access_log /var/log/nginx/deafgain-website/access.log matomo_tracking buffer=64k flush=5s;
error_log /var/log/nginx/deafgain-website/error.log error;
# Increased buffer sizes
large_client_header_buffers 8 32k;
client_header_buffer_size 32k;
client_max_body_size 10M;
client_body_buffer_size 128k;
# Security headers
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
add_header Strict-Transport-Security "max-age=31536000";
add_header Referrer-Policy "strict-origin-when-cross-origin";
# Compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# API endpoints
location /contact {
proxy_pass http://api:3000/contact;
location /api/contact {
proxy_pass http://deafgain-website-api-1:3000/contact;
proxy_http_version 1.1;
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;
# Updated log settings with smaller buffer and faster flush
access_log /var/log/nginx/deafgain-website/access.log matomo_tracking buffer=64k flush=5s;
error_log /var/log/nginx/deafgain-website/error.log error;
# CORS headers
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
@ -54,18 +40,14 @@ server {
}
}
location /subscribe {
proxy_pass http://api:3000/subscribe;
location /api/subscribe {
proxy_pass http://deafgain-website-api-1:3000/subscribe;
proxy_http_version 1.1;
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;
# Updated log settings with smaller buffer and faster flush
access_log /var/log/nginx/deafgain-website/access.log matomo_tracking buffer=64k flush=5s;
error_log /var/log/nginx/deafgain-website/error.log error;
# CORS headers
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
@ -83,49 +65,21 @@ server {
}
}
# React app - serve static files
location / {
try_files $uri $uri/ /index.html;
expires 1h;
add_header Cache-Control "public, no-transform";
}
# Video files handling
# Video files handling - serve from mounted directory
location /videos/ {
alias /usr/share/nginx/html/videos/;
add_header Cache-Control "public, no-transform";
add_header Accept-Ranges bytes;
types {
video/mp4 mp4;
}
add_header Accept-Ranges bytes;
}
# Images handling
location /images/ {
alias /usr/share/nginx/html/images/;
add_header Cache-Control "public, no-transform";
types {
image/png png;
image/jpeg jpg jpeg;
image/svg+xml svg;
}
}
# Subtitles handling
location /subtitles/ {
alias /usr/share/nginx/html/subtitles/;
add_header Cache-Control "public, no-transform";
types {
text/vtt vtt;
}
}
# Transcriptions handling
location /transcriptions/ {
alias /usr/share/nginx/html/transcriptions/;
add_header Cache-Control "public, no-transform";
types {
text/plain txt;
}
}
# Static asset caching

View file

@ -3,46 +3,51 @@ services:
build:
context: .
dockerfile: Dockerfile
container_name: deafgain-website-web-1
ports:
- "80:80"
- "804:804"
depends_on:
- api
- redis
environment:
- NODE_ENV=production
restart: unless-stopped
volumes:
- /docker/websites/deafgain/video_content:/usr/share/nginx/html/videos
networks:
- app_network
- caddy_network
- default
api:
build:
context: .
dockerfile: Dockerfile.api
container_name: deafgain-website-api-1
depends_on:
- redis
environment:
- NODE_ENV=production
- PORT=804
- PORT=3000
- GMAIL_USER=${GMAIL_USER}
- GMAIL_PASS=${GMAIL_PASS}
- REDIS_URL=redis://redis:6379
- REDIS_TOKEN=${REDIS_TOKEN}
- API_URL=http://api:804
restart: unless-stopped
networks:
- app_network
- default
redis:
image: redis:7-alpine
container_name: deafgain-website-redis-1
restart: unless-stopped
volumes:
- redis_data:/data
networks:
- app_network
- default
volumes:
redis_data:
networks:
app_network:
driver: bridge
caddy_network:
external: true

View file

@ -175,7 +175,7 @@ const Resources = () => {
setIsSubscribing(true)
try {
const response = await fetch('/subscribe', {
const response = await fetch('/api/subscribe', {
method: 'POST',
headers: {
'Content-Type': 'application/json',