Skip to content

Commit 5c29ef0

Browse files
committed
added compose.dev and changed base image to debian
1 parent 257f395 commit 5c29ef0

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

samples/react/app/Dockerfile

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
1+
# DEVELOPMENT MODE
2+
# Use slim version of Node.js v20 on Debian Bookworm as base image
3+
FROM node:20-bookworm-slim as dev
4+
5+
# Set working directory to /app
6+
WORKDIR /app
7+
8+
# Copy package files
9+
COPY package*.json ./
10+
11+
# Install dependencies
12+
RUN npm ci
13+
14+
# Copy rest of the applicationn code
15+
COPY . .
16+
17+
# Expose port 5173
18+
EXPOSE 5173
19+
20+
# Command to start the app
21+
CMD ["npm", "run", "dev"]
22+
23+
24+
25+
# PRODUCTION MODE
126
# Build stage
2-
FROM node:18-alpine as build
27+
FROM node:20-bookworm-slim as build
328

429
# Set working directory to /app
530
WORKDIR /app
@@ -17,7 +42,7 @@ COPY . .
1742
RUN npm run build
1843

1944
# Production stage
20-
FROM nginx:stable-alpine
45+
FROM nginx:stable
2146

2247
# Copy the build output from the build stage
2348
COPY --from=build /app/dist /usr/share/nginx/html
@@ -29,4 +54,4 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf
2954
EXPOSE 5173
3055

3156
# Start Nginx
32-
CMD ["nginx", "-g", "daemon off;"]
57+
CMD ["nginx", "-g", "daemon off;"]

samples/react/app/vite.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ import react from '@vitejs/plugin-react'
44
// https://vitejs.dev/config/
55
export default defineConfig({
66
plugins: [react()],
7+
server: {
8+
host: '0.0.0.0',
9+
port: 5173,
10+
},
711
})

samples/react/compose.dev.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
app:
3+
extends:
4+
file: compose.yaml
5+
service: app
6+
build:
7+
target: dev
8+
volumes:
9+
- ./app:/app
10+
- /app/node_modules
11+
command: npm run dev
12+
13+

samples/react/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ services:
1515
reservations:
1616
memory: 512M
1717
healthcheck:
18-
test: ["CMD", "wget", "-q", "--spider", "http://localhost:5173/"]
18+
test: ["CMD", "curl", "-f", "http://localhost:5173/"]

0 commit comments

Comments
 (0)