File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737 docker compose down
3838
3939 # Build new images if the Dockerfile has changed, and start the new containers in the background.
40- docker compose up --build -d
41-
42- # Optional: This cleans up any old, unused Docker images to save disk space.
43- docker image prune -af
40+ docker compose up --build -d
Original file line number Diff line number Diff line change 3737 docker-compose down
3838
3939 # Build new images if the Dockerfile has changed, and start the new containers in the background.
40- docker-compose up --build -d
41-
42- # Optional: This cleans up any old, unused Docker images to save disk space.
43- docker image prune -af
40+ docker-compose up --build -d
Original file line number Diff line number Diff line change 1+ # src/client/.dockerignore
2+
3+ # Git
4+ .git
5+ .gitignore
6+
7+ # Docker
8+ Dockerfile
9+ .dockerignore
10+ docker-compose.yml
11+
12+ # Node
13+ node_modules
14+ npm-debug.log
15+
16+ # Next.js build artifacts
17+ .next
18+ out
19+
20+ # Environment files (these should be passed in at runtime)
21+ .env
22+ .env.local
23+ .env.template
Original file line number Diff line number Diff line change 1+ # src/client/Dockerfile
2+
3+ # 1. Builder Stage: Installs dependencies and builds the app
4+ FROM node:20-slim AS builder
5+ WORKDIR /app
6+
7+ # Copy package.json and lock file to leverage Docker cache
8+ COPY package.json ./
9+ RUN npm install
10+
11+ # Copy the rest of the application source code
12+ COPY . .
13+
14+ # Build the Next.js application for production
15+ # This creates the .next/standalone folder
16+ RUN npm run build
17+
18+
19+ # 2. Runner Stage: Creates the final, lightweight image
20+ FROM node:20-alpine AS runner
21+ WORKDIR /app
22+
23+ # Set the environment to production
24+ ENV NODE_ENV=production
25+ ENV PORT=3000
26+
27+ # Copy the standalone Next.js server from the builder stage
28+ COPY --from=builder /app/.next/standalone ./
29+ # Copy public assets and static build artifacts
30+ COPY --from=builder /app/public ./public
31+ COPY --from=builder /app/.next/static ./.next/static
32+
33+ # Expose the port the app will run on
34+ EXPOSE 3000
35+
36+ # The command to start the optimized Next.js server
37+ CMD ["node" , "server.js" ]
Original file line number Diff line number Diff line change 1+ # src/client/docker-compose.yml
2+
3+ services :
4+ sentient-client :
5+ # Build the image from the Dockerfile in the current directory
6+ build : .
7+ container_name : sentient-client
8+ # Always restart the container unless it is explicitly stopped
9+ restart : unless-stopped
10+ # Map port 80 on the VM to port 3000 inside the container
11+ ports :
12+ - " 80:3000"
13+ # Load environment variables from a .env file in the same directory
14+ env_file :
15+ - .env
Original file line number Diff line number Diff line change @@ -5,4 +5,8 @@ const nextConfig = {
55 }
66}
77
8+ if ( process . env . NODE_ENV === "production" ) {
9+ nextConfig . output = "standalone"
10+ }
11+
812export default nextConfig
You can’t perform that action at this time.
0 commit comments