Prod/Dev mode

This commit is contained in:
James Pattinson
2025-11-11 16:59:58 +00:00
parent d173b13bb9
commit d42b7cb307
6 changed files with 140 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
FROM node:18-alpine
# Multi-stage Dockerfile for development and production
FROM node:18-alpine AS base
WORKDIR /app
@@ -11,8 +12,24 @@ RUN npm install
# Copy application files
COPY . .
# Expose port
# Development stage
FROM base AS development
EXPOSE 3000
# Start development server
CMD ["npm", "run", "dev"]
# Production build stage
FROM base AS build
RUN npm run build
# Production stage with Nginx
FROM nginx:alpine AS production
# Copy built files from build stage
COPY --from=build /app/dist /usr/share/nginx/html
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

36
frontend/nginx.conf Normal file
View File

@@ -0,0 +1,36 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Handle client-side routing - serve index.html for all non-file requests
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/xml+rss
application/json;
}

View File

@@ -112,7 +112,7 @@ const Dashboard: React.FC = () => {
const handleUpdateUserRole = async (userId: number, newRole: string) => {
try {
await userService.updateUserRole(userId, newRole);
await userService.updateUser(userId, { role: newRole });
// Reload data to reflect changes
await loadData();
} catch (error) {

View File

@@ -7,7 +7,7 @@ export default defineConfig({
host: true,
port: 3000,
strictPort: true,
allowedHosts: ['sasaprod', 'localhost'],
allowedHosts: ['sasaprod', 'localhost', 'members.sasalliance.org'],
watch: {
usePolling: true
},