Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions node-express-server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
.git
.env
13 changes: 13 additions & 0 deletions node-express-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Multi-stage build for a smaller, secure image
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only-production
COPY . .

FROM node:18-alpine
WORKDIR /app
COPY --from-builder /app .
EXPOSE 8080
# Note: Based on your screenshot, the main file is server.js
CMD ["node", "server.js"]
15 changes: 15 additions & 0 deletions react-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Stage 1: Build the React app
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Stage 2: Serve using Nginx
FROM nginx:alpine
# In React apps, the build output usually goes to a folder named 'build'
COPY --from-build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
8 changes: 8 additions & 0 deletions react-client/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}