diff --git a/client/.dockerignore b/client/.dockerignore new file mode 100644 index 0000000..9bbded4 --- /dev/null +++ b/client/.dockerignore @@ -0,0 +1,3 @@ +// .dockerignore +node_modules +build \ No newline at end of file diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..e8e3b9d --- /dev/null +++ b/client/Dockerfile @@ -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"] \ No newline at end of file diff --git a/client/app/Components/Globals/DummyData.ts b/client/app/Components/Globals/DummyData.ts index b0f7a3f..632d261 100644 --- a/client/app/Components/Globals/DummyData.ts +++ b/client/app/Components/Globals/DummyData.ts @@ -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, }, ]; diff --git a/client/docker-external-config.json b/client/docker-external-config.json new file mode 100644 index 0000000..052be41 --- /dev/null +++ b/client/docker-external-config.json @@ -0,0 +1,5 @@ +{ + "version": "docker-version", + "restPathRoot": "api/", + "restServiceRoot": "api/services/rest/" +} \ No newline at end of file diff --git a/client/pages/session/[id].tsx b/client/pages/session/[id].tsx index 3838fb1..5f2c37f 100644 --- a/client/pages/session/[id].tsx +++ b/client/pages/session/[id].tsx @@ -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(); diff --git a/docker-compose.yml b/docker-compose.yml index 6ed6d7a..bcbdc1f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 \ No newline at end of file + - 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 diff --git a/reverse-proxy/Dockerfile b/reverse-proxy/Dockerfile new file mode 100644 index 0000000..17db432 --- /dev/null +++ b/reverse-proxy/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:latest + +COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/reverse-proxy/nginx.conf b/reverse-proxy/nginx.conf new file mode 100644 index 0000000..6d401b2 --- /dev/null +++ b/reverse-proxy/nginx.conf @@ -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; + } + +}