Skip to content

Commit

Permalink
Merge pull request #2 from famasboy888/dev
Browse files Browse the repository at this point in the history
PR to main
  • Loading branch information
famasboy888 authored Apr 7, 2024
2 parents 0724313 + af7ecfe commit 64884ba
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 8 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,31 @@ jobs:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/react-app:0.0.${{ github.run_number }}.RELEASE
```
## Added working nginx.conf
```bash
upstream backend {
server node-server-service;
}


server {
listen 8080;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

location /api/ {
proxy_pass http://backend;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
2 changes: 2 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ FROM node:17-alpine

WORKDIR /app

COPY package.json .
COPY package*.json ./

RUN npm install
RUN npm ci

COPY . .

Expand Down
2 changes: 2 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
19 changes: 14 additions & 5 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
FROM node:20.12.0-alpine
FROM node:alpine as build

WORKDIR /app

COPY package.json .
COPY package*.json ./

RUN npm install
RUN npm ci

COPY . .

EXPOSE 8080
RUN npm run build

CMD [ "npm", "start" ]

FROM nginx:alpine

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;"]
23 changes: 23 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
upstream backend {
server node-server-service;
}


server {
listen 8080;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

location /api/ {
proxy_pass http://backend;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"proxy": "http://frontend:80",
"name": "frontend",
"version": "0.1.0",
"private": true,
Expand Down

0 comments on commit 64884ba

Please sign in to comment.