Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated docker files, integrated nginx #42

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// .dockerignore
node_modules
build
19 changes: 19 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ==== CONFIGURE =====
# Use a Node 16 base image
FROM node:lts
# Set the working directory to /app inside the container
WORKDIR /app
# Copy app files
COPY . .
# ==== BUILD =====
# Install dependencies (npm ci makes sure the exact versions in the lockfile gets installed)
RUN npm ci
# Build the app
RUN npm run build
# ==== RUN =======
# Set the env to "production"
ENV NODE_ENV development
# Expose the port on which the app will be running
EXPOSE 3000
# Start the app
CMD [ "npm", "start"]
6 changes: 2 additions & 4 deletions client/app/Components/Globals/DummyData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ export const dummyTasks: ITask[] = [
{
id: "37489248923489",
title: "Migration from LiteDb to MongoDb",
issueNumber: "37",
description:
"How long do you think would a migration from LiteDb to MongoDb take? Since we have no initial data, we can omit this step.",
isActive: false,
status: 0,
},
{
id: "3741231283913489",
title: "Move to WebSockets",
issueNumber: "38",
description: "How long do you think do we need to integrate WebSockets?",
isActive: false,
status: 3,
},
];
5 changes: 5 additions & 0 deletions client/docker-external-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": "docker-version",
"restPathRoot": "api/",
"restServiceRoot": "api/services/rest/"
}
2 changes: 1 addition & 1 deletion client/pages/session/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function getServerSideProps(context: any) {
const { id } = params;

const res = await fetch(
"http://127.0.0.1:8085/estimation/v1/session/" + id + "/status"
"http://estimation-backend:8085/estimation/v1/session/" + id + "/status"
);

const data = await res.json();
Expand Down
35 changes: 30 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
version: "3.8"

services:
dotnet-estimation:
container_name: devon4net-estimation
backend:
container_name: estimation-backend
build:
context: ./dotnet-estimation/Templates/WebAPI
dockerfile: ./dotnet-estimation/Devon4Net.Application.WebAPI/Dockerfile
context: ./dotnet-estimation/dotnet-estimation/Templates/WebAPI
dockerfile: ./Devon4Net.Application.WebAPI/Dockerfile
networks:
backend-net:
aliases: [backend]
ports:
- 8085:8085
- 8085:8085

frontend:
container_name: estimation-frontend
build:
context: ./client
networks:
backend-net:
aliases: [backend]
reverse-proxy:
build: ./reverse-proxy
restart: always
container_name: 'reverse_proxy'
ports:
- 80:80
networks:
backend-net:
aliases: [backend]

networks:
backend-net:
driver: bridge
3 changes: 3 additions & 0 deletions reverse-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:latest

COPY nginx.conf /etc/nginx/conf.d/default.conf
39 changes: 39 additions & 0 deletions reverse-proxy/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
server {
listen 80;
listen 8085;
server_name _;
root /usr/share/nginx/html;

# reverse proxy
location / {
proxy_pass http://estimation-frontend:3000;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}

# reverse proxy
location http://localhost:8085/ {
proxy_pass http://estimation-backend:8085;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}

}