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"]
|
||||
|
||||
Reference in New Issue
Block a user