update Docker deployment
This commit is contained in:
parent
b6f727be5d
commit
3e1892a6f7
5 changed files with 48 additions and 94 deletions
31
Dockerfile
31
Dockerfile
|
|
@ -2,9 +2,6 @@ FROM node:20-alpine AS base
|
||||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create required directories
|
|
||||||
RUN mkdir -p public/images/thumbnails public/subtitles public/transcriptions
|
|
||||||
|
|
||||||
# Copy package files first
|
# Copy package files first
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
|
@ -16,16 +13,6 @@ RUN pnpm install --frozen-lockfile
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
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
|
RUN pnpm build
|
||||||
|
|
||||||
# Production image
|
# Production image
|
||||||
|
|
@ -37,28 +24,14 @@ RUN mkdir -p /usr/share/nginx/html/images/thumbnails \
|
||||||
/usr/share/nginx/html/transcriptions \
|
/usr/share/nginx/html/transcriptions \
|
||||||
/usr/share/nginx/html/videos
|
/usr/share/nginx/html/videos
|
||||||
|
|
||||||
# Copy verification file from builder
|
|
||||||
COPY --from=builder /verification.txt /verification.txt
|
|
||||||
|
|
||||||
# Copy built app and static assets
|
# Copy built app and static assets
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
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/images/ /usr/share/nginx/html/images/
|
||||||
COPY --from=builder /app/public/subtitles /usr/share/nginx/html/subtitles
|
COPY --from=builder /app/public/subtitles /usr/share/nginx/html/subtitles
|
||||||
COPY --from=builder /app/public/transcriptions /usr/share/nginx/html/transcriptions
|
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/
|
|
||||||
|
|
||||||
|
# Copy nginx configuration
|
||||||
# Add runner stage verification to the file
|
COPY default.conf /etc/nginx/conf.d/default.conf
|
||||||
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
|
|
||||||
|
|
||||||
EXPOSE 804
|
EXPOSE 804
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,30 @@
|
||||||
# Active Context - Current Work Status
|
# Active Context - Current Work Status
|
||||||
|
|
||||||
## Recently Completed Work
|
## Recently Completed Work
|
||||||
**Date: 5/27/2025**
|
**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
|
### ✅ Governance Documents Video Integration - COMPLETED
|
||||||
Successfully added the new "Governance Documents: Understanding the Hierarchy" video to the DeafGain website:
|
Successfully added the new "Governance Documents: Understanding the Hierarchy" video to the DeafGain website:
|
||||||
|
|
||||||
|
|
|
||||||
64
default.conf
64
default.conf
|
|
@ -1,42 +1,28 @@
|
||||||
server {
|
server {
|
||||||
listen 804;
|
listen 804;
|
||||||
server_name localhost;
|
server_name _;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.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
|
# Security headers
|
||||||
add_header X-Frame-Options "SAMEORIGIN";
|
add_header X-Frame-Options "SAMEORIGIN";
|
||||||
add_header X-XSS-Protection "1; mode=block";
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
add_header X-Content-Type-Options "nosniff";
|
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
|
# Compression
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
|
||||||
# API endpoints
|
# API endpoints
|
||||||
location /contact {
|
location /api/contact {
|
||||||
proxy_pass http://api:3000/contact;
|
proxy_pass http://deafgain-website-api-1:3000/contact;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
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
|
# CORS headers
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
|
@ -54,18 +40,14 @@ server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
location /subscribe {
|
location /api/subscribe {
|
||||||
proxy_pass http://api:3000/subscribe;
|
proxy_pass http://deafgain-website-api-1:3000/subscribe;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
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
|
# CORS headers
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
|
@ -83,49 +65,21 @@ server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# React app - serve static files
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
expires 1h;
|
expires 1h;
|
||||||
add_header Cache-Control "public, no-transform";
|
add_header Cache-Control "public, no-transform";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Video files handling
|
# Video files handling - serve from mounted directory
|
||||||
location /videos/ {
|
location /videos/ {
|
||||||
alias /usr/share/nginx/html/videos/;
|
alias /usr/share/nginx/html/videos/;
|
||||||
add_header Cache-Control "public, no-transform";
|
add_header Cache-Control "public, no-transform";
|
||||||
|
add_header Accept-Ranges bytes;
|
||||||
types {
|
types {
|
||||||
video/mp4 mp4;
|
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
|
# Static asset caching
|
||||||
|
|
|
||||||
|
|
@ -3,46 +3,51 @@ services:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
container_name: deafgain-website-web-1
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "804:804"
|
||||||
depends_on:
|
depends_on:
|
||||||
- api
|
- api
|
||||||
- redis
|
- redis
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- /docker/websites/deafgain/video_content:/usr/share/nginx/html/videos
|
||||||
networks:
|
networks:
|
||||||
- app_network
|
- caddy_network
|
||||||
|
- default
|
||||||
|
|
||||||
api:
|
api:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.api
|
dockerfile: Dockerfile.api
|
||||||
|
container_name: deafgain-website-api-1
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- PORT=804
|
- PORT=3000
|
||||||
- GMAIL_USER=${GMAIL_USER}
|
- GMAIL_USER=${GMAIL_USER}
|
||||||
- GMAIL_PASS=${GMAIL_PASS}
|
- GMAIL_PASS=${GMAIL_PASS}
|
||||||
- REDIS_URL=redis://redis:6379
|
- REDIS_URL=redis://redis:6379
|
||||||
- REDIS_TOKEN=${REDIS_TOKEN}
|
- REDIS_TOKEN=${REDIS_TOKEN}
|
||||||
- API_URL=http://api:804
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- app_network
|
- default
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
|
container_name: deafgain-website-redis-1
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
networks:
|
networks:
|
||||||
- app_network
|
- default
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
redis_data:
|
redis_data:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
app_network:
|
caddy_network:
|
||||||
driver: bridge
|
external: true
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ const Resources = () => {
|
||||||
setIsSubscribing(true)
|
setIsSubscribing(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/subscribe', {
|
const response = await fetch('/api/subscribe', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue