anuragshas commited on
Commit
8f11ac1
·
1 Parent(s): 40032c3

add: deployment files

Browse files
Files changed (5) hide show
  1. .dockerignore +15 -0
  2. Dockerfile +32 -0
  3. deploy.sh +27 -0
  4. docker-compose.yml +26 -0
  5. nginx.conf +57 -0
.dockerignore ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ node_modules
2
+ npm-debug.log*
3
+ yarn-debug.log*
4
+ yarn-error.log*
5
+ .git
6
+ .gitignore
7
+ README.md
8
+ .env
9
+ .nyc_output
10
+ coverage
11
+ .husky
12
+ .parcel-cache
13
+ dist
14
+ tests
15
+ *.md
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stage 1: Build stage
2
+ FROM node:18-alpine AS builder
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Copy package files
8
+ COPY package*.json ./
9
+
10
+ # Install dependencies
11
+ RUN npm ci --only=production=false
12
+
13
+ # Copy source code
14
+ COPY . .
15
+
16
+ # Build the application
17
+ RUN npm run build
18
+
19
+ # Stage 2: Production stage
20
+ FROM nginx:alpine AS production
21
+
22
+ # Copy built application from builder stage
23
+ COPY --from=builder /app/dist /usr/share/nginx/html
24
+
25
+ # Copy custom nginx configuration
26
+ COPY nginx.conf /etc/nginx/nginx.conf
27
+
28
+ # Expose port 80
29
+ EXPOSE 80
30
+
31
+ # Start nginx
32
+ CMD ["nginx", "-g", "daemon off;"]
deploy.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Build and deploy script for invoice generator
4
+
5
+ set -e
6
+
7
+ echo "🚀 Starting deployment process..."
8
+
9
+ # Build the Docker image
10
+ echo "📦 Building Docker image..."
11
+ docker build -t invoice-generator:latest .
12
+
13
+ # Stop and remove existing container if running
14
+ echo "🛑 Stopping existing container..."
15
+ docker stop invoice-generator-app 2>/dev/null || true
16
+ docker rm invoice-generator-app 2>/dev/null || true
17
+
18
+ # Run the new container
19
+ echo "▶️ Starting new container..."
20
+ docker run -d \
21
+ --name invoice-generator-app \
22
+ --restart unless-stopped \
23
+ -p 8080:80 \
24
+ invoice-generator:latest
25
+
26
+ echo "✅ Deployment completed successfully!"
27
+ echo "🌐 Application is available at: http://localhost:8080"
docker-compose.yml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: "3.8"
2
+
3
+ services:
4
+ invoice-generator:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ target: production
9
+ ports:
10
+ - "8080:80"
11
+ restart: unless-stopped
12
+ container_name: invoice-generator-app
13
+
14
+ # Development service (optional)
15
+ invoice-generator-dev:
16
+ build:
17
+ context: .
18
+ dockerfile: Dockerfile
19
+ target: builder
20
+ ports:
21
+ - "1234:1234"
22
+ volumes:
23
+ - .:/app
24
+ - /app/node_modules
25
+ command: npm run dev
26
+ profiles: ["dev"]
nginx.conf ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ events {
2
+ worker_connections 1024;
3
+ }
4
+
5
+ http {
6
+ include /etc/nginx/mime.types;
7
+ default_type application/octet-stream;
8
+
9
+ # Logging
10
+ access_log /var/log/nginx/access.log;
11
+ error_log /var/log/nginx/error.log;
12
+
13
+ # Gzip compression
14
+ gzip on;
15
+ gzip_vary on;
16
+ gzip_min_length 1024;
17
+ gzip_proxied any;
18
+ gzip_comp_level 6;
19
+ gzip_types
20
+ text/plain
21
+ text/css
22
+ text/xml
23
+ text/javascript
24
+ application/javascript
25
+ application/xml+rss
26
+ application/json;
27
+
28
+ # Security headers
29
+ add_header X-Frame-Options "SAMEORIGIN" always;
30
+ add_header X-XSS-Protection "1; mode=block" always;
31
+ add_header X-Content-Type-Options "nosniff" always;
32
+ add_header Referrer-Policy "no-referrer-when-downgrade" always;
33
+ add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
34
+
35
+ server {
36
+ listen 80;
37
+ server_name _;
38
+ root /usr/share/nginx/html;
39
+ index index.html;
40
+
41
+ # Cache static assets
42
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
43
+ expires 1y;
44
+ add_header Cache-Control "public, immutable";
45
+ }
46
+
47
+ # Handle SPA routing
48
+ location / {
49
+ try_files $uri $uri/ /index.html;
50
+ }
51
+
52
+ # Security
53
+ location ~ /\. {
54
+ deny all;
55
+ }
56
+ }
57
+ }