From 0aa386b490e7370683961fd408fd8e1230a36c99 Mon Sep 17 00:00:00 2001 From: sid palas Date: Sun, 12 Feb 2023 15:34:02 -0500 Subject: [PATCH] Add instructions for running the app without docker --- 05-example-web-application/Makefile | 11 +++--- 05-example-web-application/README.md | 34 ++++++++++++++++-- .../api-golang/Makefile | 4 --- 05-example-web-application/api-node/Makefile | 13 ------- .../app-screenshot.png | Bin .../{images => readme-assets}/tech-stack.png | Bin 6 files changed, 37 insertions(+), 25 deletions(-) delete mode 100644 05-example-web-application/api-golang/Makefile delete mode 100644 05-example-web-application/api-node/Makefile rename 05-example-web-application/{images => readme-assets}/app-screenshot.png (100%) rename 05-example-web-application/{images => readme-assets}/tech-stack.png (100%) diff --git a/05-example-web-application/Makefile b/05-example-web-application/Makefile index ff8c348..c947ae2 100644 --- a/05-example-web-application/Makefile +++ b/05-example-web-application/Makefile @@ -1,8 +1,11 @@ +DATABASE_URL:=postgres://postgres:foobarbaz@localhost:5432/postgres + .PHONY: run-postgres run-postgres: @echo Starting postgres container -docker run \ -e POSTGRES_PASSWORD=foobarbaz \ + -v pgdata:/var/lib/postgresql/data \ -p 5432:5432 \ postgres:15.1-alpine @@ -10,18 +13,14 @@ run-postgres: run-api-node: @echo Starting node api cd api-node && \ - PGUSER=postgres \ - PGHOST=localhost \ - PGPASSWORD=foobarbaz \ - PGDATABASE=postgres \ - PGPORT=5432 \ + DATABASE_URL=${DATABASE_URL} \ npm run dev .PHONY: run-api-golang run-api-golang: @echo Starting golang api cd api-golang && \ - DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres \ + DATABASE_URL=${DATABASE_URL} \ go run main.go .PHONY: run-client-react diff --git a/05-example-web-application/README.md b/05-example-web-application/README.md index 4875c2d..9dc5fff 100644 --- a/05-example-web-application/README.md +++ b/05-example-web-application/README.md @@ -1,10 +1,40 @@ # Sample web application -![](./images/app-screenshot.png) +![](./readme-assets/app-screenshot.png) ## Minimal 3 tier web application - React frontend - Node JS and Golang APIs - Postgres Database -![](./images/tech-stack.png) +![](./readme-assets/tech-stack.png) + +## Running the Application + +While the whole point of this course is that you probably won't want/need to run the application locally (See: `11-development-workflow`), we can do so as a starting point. + +The `Makefile` contains the commands to start each application. + +### Postgres + +It's way more convenient to run postgres in a container as we saw in `04-using-3rd-party-containers`, so we will do that. + +`make run-postgres` will start postgres in a container and publish port 5432 from the container to your localhost. + +### api-node + +To run the node api you will need to run `npm install` to install the dependencies (I used node `v19.4.0` and npm `v9.2.0`). + +After installing the dependencies, `make run-api-node` will run the api in development mode with nodemon for restarting the app when you make source code changes. + +### api-golang + +To run the golang api you will need to run `go mod download` to download and install the dependencies (I used `go1.19.1`) + +After installing the dependencies, `make run-api-golang` will build and run the api. + +### client-react + +Like `api-node`, you will first need to install the dependencies with `npm install` (again, I used node `v19.4.0` and npm `v9.2.0`) + +After installing the dependencies, `make run-client-react` will use vite to run the react app in development mode. \ No newline at end of file diff --git a/05-example-web-application/api-golang/Makefile b/05-example-web-application/api-golang/Makefile deleted file mode 100644 index f3c1a9f..0000000 --- a/05-example-web-application/api-golang/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -.PHONY: run-local -run-local: - DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres \ - go run main.go diff --git a/05-example-web-application/api-node/Makefile b/05-example-web-application/api-node/Makefile deleted file mode 100644 index 241407c..0000000 --- a/05-example-web-application/api-node/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres - -.PHONY: run-local -run-local: - DATABASE_URL=${DATABASE_URL} npm run dev - -.PHONY: run-local-debug -run-local-debug: - DATABASE_URL=${DATABASE_URL} npm run debug - -.PHONY: build-naive -build-naive: - docker build --file ./Dockerfile.naive . diff --git a/05-example-web-application/images/app-screenshot.png b/05-example-web-application/readme-assets/app-screenshot.png similarity index 100% rename from 05-example-web-application/images/app-screenshot.png rename to 05-example-web-application/readme-assets/app-screenshot.png diff --git a/05-example-web-application/images/tech-stack.png b/05-example-web-application/readme-assets/tech-stack.png similarity index 100% rename from 05-example-web-application/images/tech-stack.png rename to 05-example-web-application/readme-assets/tech-stack.png