Skip to content

Commit 0aa386b

Browse files
committed
Add instructions for running the app without docker
1 parent a7cc85c commit 0aa386b

6 files changed

Lines changed: 37 additions & 25 deletions

File tree

‎05-example-web-application/Makefile‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1+
DATABASE_URL:=postgres://postgres:foobarbaz@localhost:5432/postgres
2+
13
.PHONY: run-postgres
24
run-postgres:
35
@echo Starting postgres container
46
-docker run \
57
-e POSTGRES_PASSWORD=foobarbaz \
8+
-v pgdata:/var/lib/postgresql/data \
69
-p 5432:5432 \
710
postgres:15.1-alpine
811

912
.PHONY: run-api-node
1013
run-api-node:
1114
@echo Starting node api
1215
cd api-node && \
13-
PGUSER=postgres \
14-
PGHOST=localhost \
15-
PGPASSWORD=foobarbaz \
16-
PGDATABASE=postgres \
17-
PGPORT=5432 \
16+
DATABASE_URL=${DATABASE_URL} \
1817
npm run dev
1918

2019
.PHONY: run-api-golang
2120
run-api-golang:
2221
@echo Starting golang api
2322
cd api-golang && \
24-
DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres \
23+
DATABASE_URL=${DATABASE_URL} \
2524
go run main.go
2625

2726
.PHONY: run-client-react
Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
11
# Sample web application
22

3-
![](./images/app-screenshot.png)
3+
![](./readme-assets/app-screenshot.png)
44

55
## Minimal 3 tier web application
66
- React frontend
77
- Node JS and Golang APIs
88
- Postgres Database
99

10-
![](./images/tech-stack.png)
10+
![](./readme-assets/tech-stack.png)
11+
12+
## Running the Application
13+
14+
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.
15+
16+
The `Makefile` contains the commands to start each application.
17+
18+
### Postgres
19+
20+
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.
21+
22+
`make run-postgres` will start postgres in a container and publish port 5432 from the container to your localhost.
23+
24+
### api-node
25+
26+
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`).
27+
28+
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.
29+
30+
### api-golang
31+
32+
To run the golang api you will need to run `go mod download` to download and install the dependencies (I used `go1.19.1`)
33+
34+
After installing the dependencies, `make run-api-golang` will build and run the api.
35+
36+
### client-react
37+
38+
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`)
39+
40+
After installing the dependencies, `make run-client-react` will use vite to run the react app in development mode.

‎05-example-web-application/api-golang/Makefile‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎05-example-web-application/api-node/Makefile‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

05-example-web-application/images/app-screenshot.png renamed to 05-example-web-application/readme-assets/app-screenshot.png

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)