From 97fa467b95cdee2c2766f642b5c46d1ab0b8c42b Mon Sep 17 00:00:00 2001 From: Toni Tienda Date: Thu, 21 Mar 2024 09:57:40 +0100 Subject: [PATCH] feat: adds docker-compose to run webapp and backend side by side --- docker-compose.yaml | 16 ++++++++++++++++ webapp-react/src/api/tasks.ts | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..6d0ef78 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +version: '3.7' +services: + backend: + build: + context: ./backend-golang-rest + dockerfile: Dockerfile + ports: + - 8080:8080 + webapp: + build: + context: ./webapp-react + dockerfile: Dockerfile + ports: + - 3000:3000 + depends_on: + - backend \ No newline at end of file diff --git a/webapp-react/src/api/tasks.ts b/webapp-react/src/api/tasks.ts index a003133..18077e6 100644 --- a/webapp-react/src/api/tasks.ts +++ b/webapp-react/src/api/tasks.ts @@ -1,5 +1,5 @@ export async function getTasks() { - const res = await fetch("http://localhost:8080/v0/tasks?t=1", { + const res = await fetch("http://backend:8080/v0/tasks", { cache: "no-store", headers: { "X-User-ID": "b78fe6be-0642-4cfa-9f19-9cc8e53b129d", @@ -17,7 +17,7 @@ export async function getTasks() { } export async function addTask() { - const res = await fetch("http://localhost:8080/v0/tasks", { + const res = await fetch("http://backend:8080/v0/tasks", { method: "POST", body: JSON.stringify({ title: "New task",