Skip to content

Commit f0c7d2d

Browse files
committed
add docker config
1 parent 85dba4c commit f0c7d2d

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed

.dockerignore

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Dependencies
2+
node_modules
3+
4+
# Build outputs
5+
build
6+
dist
7+
8+
# Configuration files
9+
.env
10+
.env.local
11+
.env.development.local
12+
.env.test.local
13+
.env.production.local
14+
15+
# Logs
16+
npm-debug.log*
17+
yarn-debug.log*
18+
yarn-error.log*
19+
pnpm-debug.log*
20+
21+
# Runtime data
22+
pids
23+
*.pid
24+
*.seed
25+
*.pid.lock
26+
27+
# Directory for instrumented libs generated by jscoverage/JSCover
28+
lib-cov
29+
30+
# Coverage directory used by tools like istanbul
31+
coverage
32+
*.lcov
33+
34+
# nyc test coverage
35+
.nyc_output
36+
37+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
38+
.grunt
39+
40+
# Bower dependency directory (https://bower.io/)
41+
bower_components
42+
43+
# node-waf configuration
44+
.lock-wscript
45+
46+
# Compiled binary addons (https://nodejs.org/api/addons.html)
47+
build/Release
48+
49+
# Dependency directories
50+
jspm_packages
51+
52+
# TypeScript v1 declaration files
53+
typings
54+
55+
# TypeScript cache
56+
*.tsbuildinfo
57+
58+
# Optional npm cache directory
59+
.npm
60+
61+
# Optional eslint cache
62+
.eslintcache
63+
64+
# Microbundle cache
65+
.rpt2_cache/
66+
.rts2_cache_cjs/
67+
.rts2_cache_es/
68+
.rts2_cache_umd/
69+
70+
# Optional REPL history
71+
.node_repl_history
72+
73+
# Output of 'npm pack'
74+
*.tgz
75+
76+
# Yarn
77+
.yarn-integrity
78+
.yarn/cache
79+
.yarn/unplugged
80+
.yarn/build-state.yml
81+
.yarn/install-state.gz
82+
.pnp.*
83+
84+
# Docker
85+
Dockerfile*
86+
docker-compose*
87+
.dockerignore
88+
89+
# IDEs
90+
.vscode
91+
.idea
92+
*.swp
93+
*.swo
94+
95+
# OS generated files
96+
.DS_Store
97+
Thumbs.db
98+
99+
# Testing
100+
coverage/
101+
.nyc_output/
102+
103+
# Documentation
104+
docs/

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Multi-stage Dockerfile for React application
2+
# Stage 1: Build the application
3+
FROM node:23-alpine AS builder
4+
5+
# Set working directory
6+
WORKDIR /app
7+
8+
# Copy package files
9+
COPY package*.json ./
10+
11+
# Install dependencies
12+
RUN npm ci
13+
14+
# Copy source code
15+
COPY . .
16+
17+
# Build the application
18+
RUN npm run build
19+
20+
# Stage 2: Serve the application
21+
FROM nginx:alpine
22+
23+
# Copy built application from builder stage to nginx static directory
24+
COPY --from=builder /app/build /usr/share/nginx/html
25+
26+
# Copy nginx configuration
27+
COPY nginx.conf /etc/nginx/nginx.conf
28+
29+
# Expose port 80
30+
EXPOSE 80
31+
32+
# Start nginx
33+
CMD ["nginx", "-g", "daemon off;"]

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build: .
6+
ports:
7+
- "80:80"
8+
restart: unless-stopped

nginx.conf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
events {
2+
worker_connections 1024;
3+
}
4+
5+
http {
6+
include /etc/nginx/mime.types;
7+
default_type application/octet-stream;
8+
9+
# Log format
10+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
11+
'$status $body_bytes_sent "$http_referer" '
12+
'"$http_user_agent" "$http_x_forwarded_for"';
13+
14+
access_log /var/log/nginx/access.log main;
15+
error_log /var/log/nginx/error.log;
16+
17+
sendfile on;
18+
tcp_nopush on;
19+
tcp_nodelay on;
20+
keepalive_timeout 65;
21+
types_hash_max_size 2048;
22+
23+
# Gzip compression
24+
gzip on;
25+
gzip_vary on;
26+
gzip_min_length 1024;
27+
gzip_proxied any;
28+
gzip_comp_level 6;
29+
gzip_types
30+
text/plain
31+
text/css
32+
text/xml
33+
text/javascript
34+
application/json
35+
application/javascript
36+
application/xml+rss
37+
application/atom+xml
38+
image/svg+xml;
39+
40+
# Server block
41+
server {
42+
listen 80;
43+
server_name localhost;
44+
45+
# Serve static files directly
46+
location / {
47+
root /usr/share/nginx/html;
48+
index index.html index.htm;
49+
try_files $uri $uri/ /index.html;
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)