From 05121a6e6bc79e12b40e0abd56faae4c0a38fa02 Mon Sep 17 00:00:00 2001
From: NIMESH GARG <51132740+nimeshgarg@users.noreply.github.com>
Date: Sun, 2 Jun 2024 14:10:00 +1000
Subject: [PATCH 1/8] Docker fil
---
front-end/Dockerfile | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 front-end/Dockerfile
diff --git a/front-end/Dockerfile b/front-end/Dockerfile
new file mode 100644
index 0000000..4432da6
--- /dev/null
+++ b/front-end/Dockerfile
@@ -0,0 +1,8 @@
+FROM node:20-alpine as build
+WORKDIR /app
+COPY package.json .
+RUN npm install
+COPY . .
+RUN npm run build
+EXPOSE 80
+CMD [ "npm" , "run" , "preview" ]
\ No newline at end of file
From 69fc72af09cf84aa70008ee9f32b4f02b91e72bc Mon Sep 17 00:00:00 2001
From: NIMESH GARG <51132740+nimeshgarg@users.noreply.github.com>
Date: Sun, 2 Jun 2024 14:10:08 +1000
Subject: [PATCH 2/8] Vite Config
---
front-end/vite.config.js | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/front-end/vite.config.js b/front-end/vite.config.js
index 626507e..a33d5cb 100644
--- a/front-end/vite.config.js
+++ b/front-end/vite.config.js
@@ -3,11 +3,19 @@ import react from '@vitejs/plugin-react-swc'
// https://vitejs.dev/config/
export default defineConfig({
+ base:"/",
server: {
+ port: 80,
+ strictPort: true,
+ host: true,
watch: {
usePolling: true
}
},
+ preview: {
+ port: 80,
+ strictPort: true,
+ },
plugins: [react({
include: "**/*.jsx",
})]
From f651b75deff5c349381965b66ededb69a5624eae Mon Sep 17 00:00:00 2001
From: NIMESH GARG <51132740+nimeshgarg@users.noreply.github.com>
Date: Sun, 2 Jun 2024 15:14:51 +1000
Subject: [PATCH 3/8] production build
---
backend/Dockerfile | 2 ++
front-end/Dockerfile | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/backend/Dockerfile b/backend/Dockerfile
index 257638b..92fc369 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -10,4 +10,6 @@ RUN poetry install --no-root
COPY brewbucks brewbucks
+EXPOSE 80
+
CMD ["poetry", "run", "flask", "--app", "brewbucks", "run", "--host", "0.0.0.0", "--port", "80"]
\ No newline at end of file
diff --git a/front-end/Dockerfile b/front-end/Dockerfile
index 4432da6..9b171a5 100644
--- a/front-end/Dockerfile
+++ b/front-end/Dockerfile
@@ -4,5 +4,7 @@ COPY package.json .
RUN npm install
COPY . .
RUN npm run build
+RUN npm install -g serve
EXPOSE 80
-CMD [ "npm" , "run" , "preview" ]
\ No newline at end of file
+CMD [ "serve" , "-s" , "dist" , "-p" , "80"]
+# CMD [ "npm" , "run" , "preview" ]
\ No newline at end of file
From 00e95422062021ddba394a6e48e0616cc3901863 Mon Sep 17 00:00:00 2001
From: NIMESH GARG <51132740+nimeshgarg@users.noreply.github.com>
Date: Sun, 2 Jun 2024 15:31:05 +1000
Subject: [PATCH 4/8] health route
---
front-end/src/App.jsx | 3 +++
1 file changed, 3 insertions(+)
diff --git a/front-end/src/App.jsx b/front-end/src/App.jsx
index 8cb5864..733e1da 100644
--- a/front-end/src/App.jsx
+++ b/front-end/src/App.jsx
@@ -16,6 +16,9 @@ function App() {
}>
}>
}>
+
+ Hey! Healthy Here
+
)
From 2ad51fe3e885af9ffcdea6ef2c88b35be889c473 Mon Sep 17 00:00:00 2001
From: NIMESH GARG <51132740+nimeshgarg@users.noreply.github.com>
Date: Sun, 2 Jun 2024 16:22:26 +1000
Subject: [PATCH 5/8] removing health
---
front-end/src/App.jsx | 3 ---
1 file changed, 3 deletions(-)
diff --git a/front-end/src/App.jsx b/front-end/src/App.jsx
index 733e1da..8cb5864 100644
--- a/front-end/src/App.jsx
+++ b/front-end/src/App.jsx
@@ -16,9 +16,6 @@ function App() {
}>
}>
}>
-
- Hey! Healthy Here
-
)
From c1bd0af20571e3908acf9441ba0ef9c643c8ac5e Mon Sep 17 00:00:00 2001
From: NIMESH GARG <51132740+nimeshgarg@users.noreply.github.com>
Date: Sun, 2 Jun 2024 16:22:47 +1000
Subject: [PATCH 6/8] adding frontend images
---
images.tf | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/images.tf b/images.tf
index 2ef73e6..094b7a7 100644
--- a/images.tf
+++ b/images.tf
@@ -12,3 +12,18 @@ resource "docker_registry_image" "brewbucks" {
resource "aws_ecr_repository" "brewbucks" {
name = "brewbucks"
}
+
+resource "docker_registry_image" "brewbucks-frontend" {
+ name = docker_image.brewbucks-frontend.name
+}
+
+resource "docker_image" "brewbucks-frontend" {
+ name = "${aws_ecr_repository.brewbucks-frontend.repository_url}:latest"
+ build {
+ context = "./front-end/."
+ }
+}
+
+resource "aws_ecr_repository" "brewbucks-frontend" {
+ name = "brewbucks-frontend"
+}
\ No newline at end of file
From 27fec053fd53f33b776ee5adcf71d1f5057f15d1 Mon Sep 17 00:00:00 2001
From: NIMESH GARG <51132740+nimeshgarg@users.noreply.github.com>
Date: Sun, 2 Jun 2024 16:23:03 +1000
Subject: [PATCH 7/8] ecs with load balancer
---
ecs.tf | 57 +++++++++++++++++++++++++++++++++++++++
loadbalancer.tf | 72 +++++++++++++++++++++++++++++++++++++------------
2 files changed, 112 insertions(+), 17 deletions(-)
diff --git a/ecs.tf b/ecs.tf
index 4d80005..0d283b3 100644
--- a/ecs.tf
+++ b/ecs.tf
@@ -2,6 +2,43 @@ resource "aws_ecs_cluster" "brewbucks" {
name = "brewbucks"
}
+resource "aws_ecs_task_definition" "brewbucks-frontend" {
+ family = "brewbucks-frontend"
+ network_mode = "awsvpc"
+ requires_compatibilities = ["FARGATE"]
+ cpu = 1024
+ memory = 2048
+ execution_role_arn = data.aws_iam_role.lab.arn
+ depends_on = [docker_image.brewbucks-frontend]
+
+ container_definitions = <
Date: Sun, 2 Jun 2024 17:07:16 +1000
Subject: [PATCH 8/8] env for api call
---
ecs.tf | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/ecs.tf b/ecs.tf
index 0d283b3..80f9382 100644
--- a/ecs.tf
+++ b/ecs.tf
@@ -25,6 +25,12 @@ resource "aws_ecs_task_definition" "brewbucks-frontend" {
"hostPort": 80
}
],
+ "environment": [
+ {
+ "name": "BASE_URL",
+ "value": "http://${aws_lb.brewbucks.dns_name}"
+ }
+ ],
"logConfiguration": {
"logDriver": "awslogs",
"options": {