first commit
This commit is contained in:
27
Dockerfile
27
Dockerfile
@@ -1,5 +1,5 @@
|
||||
# Build stage
|
||||
FROM node:20-alpine as build
|
||||
FROM node:20-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -23,16 +23,23 @@ ENV VITE_APPWRITE_PROJECT_ID=$VITE_APPWRITE_PROJECT_ID
|
||||
# Build the app
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM nginx:alpine
|
||||
# Production stage - lightweight Node.js server
|
||||
FROM node:20-alpine
|
||||
|
||||
# Copy built files
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
WORKDIR /app
|
||||
|
||||
# Copy nginx config
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
# Install serve globally
|
||||
RUN npm install -g serve
|
||||
|
||||
# Expose port
|
||||
EXPOSE 80
|
||||
# Copy built files from build stage
|
||||
COPY --from=build /app/dist ./dist
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
# Run as non-root user for security
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nodejs -u 1001 -G nodejs && \
|
||||
chown -R nodejs:nodejs /app
|
||||
|
||||
USER nodejs
|
||||
|
||||
# Start serve on port 3000
|
||||
CMD ["serve", "-s", "dist", "-l", "3000"]
|
||||
|
||||
21
nginx.conf
21
nginx.conf
@@ -1,21 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Gzip compression
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
# Handle SPA routing - redirect all requests to index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user