File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Use the official Node.js runtime as the base image
2
+ FROM node:20 as build
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy package.json and yarn.lock to the working directory
8
+ COPY package.json yarn.lock ./
9
+
10
+ # Install dependencies
11
+ RUN yarn install
12
+
13
+ # Copy the entire application code to the container
14
+ COPY . .
15
+
16
+ # Set environment variables for production
17
+ ENV VITE_APP_DEBUG=false
18
+
19
+ # Build the React app for production
20
+ RUN yarn build
21
+
22
+ # Use Nginx as the production server
23
+ FROM nginx:alpine
24
+
25
+ # Copy the built React app to Nginx's web server directory
26
+ COPY --from=build /app/dist /usr/share/nginx/html
27
+
28
+ # Copy the Nginx configuration file to the container
29
+ COPY nginx.conf /etc/nginx/nginx.conf
30
+
31
+ # Expose port 80 for the Nginx server
32
+ EXPOSE 80
33
+
34
+ # Start Nginx when the container runs
35
+ CMD ["nginx" , "-g" , "daemon off;" ]
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ This template is built using the official Vite template for React with TypeScrip
12
12
- [ Prettier] ( https://prettier.io/ ) for code formatting.
13
13
- [ Husky] ( https://typicode.github.io/husky/#/ ) for Git hooks to automate tasks such as linting, formatting, and testing before commits.
14
14
- CI (Continuous Integration) setup with [ GitHub Actions] ( https://github.com/features/actions ) for automated testing and building.
15
+ - Docker support for containerizing the application.
15
16
16
17
## Project Structure
17
18
Original file line number Diff line number Diff line change
1
+ user nginx;
2
+ worker_processes auto;
3
+ error_log /var/log/nginx/error.log warn ;
4
+ pid /var/run/nginx.pid;
5
+
6
+ events {
7
+ worker_connections 1024 ;
8
+ }
9
+
10
+ http {
11
+ include /etc/nginx/mime.types;
12
+ default_type application/octet-stream;
13
+ log_format main '$remote_addr - $remote_user [$time_local ] "$request " '
14
+ '$status $body_bytes_sent "$http_referer " '
15
+ '"$http_user_agent " "$http_x_forwarded_for "' ;
16
+ access_log /var/log/nginx/access.log main ;
17
+ sendfile on ;
18
+
19
+ keepalive_timeout 65 ;
20
+
21
+ server {
22
+ listen 80 ;
23
+
24
+ location / {
25
+ root /usr/share/nginx/html;
26
+ index index.html index.htm;
27
+ try_files $uri $uri / /index.html;
28
+ }
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments