noumanjavaid commited on
Commit
19385bc
·
verified ·
1 Parent(s): bab3023

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +50 -0
Dockerfile ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Build stage
2
+ FROM node:18-alpine AS build
3
+
4
+ WORKDIR /app
5
+
6
+ # Copy package files and install dependencies
7
+ COPY package*.json ./
8
+ RUN npm ci
9
+
10
+ # Copy source code
11
+ COPY . .
12
+
13
+ # Build the application
14
+ RUN npm run build
15
+
16
+ # Production stage
17
+ FROM node:18-alpine
18
+
19
+ WORKDIR /app
20
+
21
+ # Create a non-root user
22
+ RUN addgroup -S appgroup && adduser -S appuser -G appgroup
23
+
24
+ # Copy only production dependencies
25
+ COPY package*.json ./
26
+ RUN npm ci --only=production
27
+
28
+ # Copy built application from build stage
29
+ COPY --from=build /app/dist ./dist
30
+ COPY --from=build /app/server.cjs ./
31
+ COPY --from=build /app/api ./api
32
+
33
+ # Set environment variables
34
+ ENV NODE_ENV=production
35
+ ENV PORT=3001
36
+
37
+ # Create a directory for environment files
38
+ RUN mkdir -p /app/config
39
+
40
+ # Note: Environment variables should be passed at runtime
41
+ # Example: docker run -e GEMINI_API_KEY=your_key -e DATABASE_URL=your_url ...
42
+
43
+ # Expose the port
44
+ EXPOSE 3001
45
+
46
+ # Switch to non-root user
47
+ USER appuser
48
+
49
+ # Start the server
50
+ CMD ["node", "server.cjs"]