Add instructions for running the app without docker

This commit is contained in:
sid palas
2023-02-12 15:34:02 -05:00
parent a7cc85c1cb
commit 0aa386b490
6 changed files with 37 additions and 25 deletions

View File

@ -1,8 +1,11 @@
DATABASE_URL:=postgres://postgres:foobarbaz@localhost:5432/postgres
.PHONY: run-postgres .PHONY: run-postgres
run-postgres: run-postgres:
@echo Starting postgres container @echo Starting postgres container
-docker run \ -docker run \
-e POSTGRES_PASSWORD=foobarbaz \ -e POSTGRES_PASSWORD=foobarbaz \
-v pgdata:/var/lib/postgresql/data \
-p 5432:5432 \ -p 5432:5432 \
postgres:15.1-alpine postgres:15.1-alpine
@ -10,18 +13,14 @@ run-postgres:
run-api-node: run-api-node:
@echo Starting node api @echo Starting node api
cd api-node && \ cd api-node && \
PGUSER=postgres \ DATABASE_URL=${DATABASE_URL} \
PGHOST=localhost \
PGPASSWORD=foobarbaz \
PGDATABASE=postgres \
PGPORT=5432 \
npm run dev npm run dev
.PHONY: run-api-golang .PHONY: run-api-golang
run-api-golang: run-api-golang:
@echo Starting golang api @echo Starting golang api
cd api-golang && \ cd api-golang && \
DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres \ DATABASE_URL=${DATABASE_URL} \
go run main.go go run main.go
.PHONY: run-client-react .PHONY: run-client-react

View File

@ -1,10 +1,40 @@
# Sample web application # Sample web application
![](./images/app-screenshot.png) ![](./readme-assets/app-screenshot.png)
## Minimal 3 tier web application ## Minimal 3 tier web application
- React frontend - React frontend
- Node JS and Golang APIs - Node JS and Golang APIs
- Postgres Database - 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.

View File

@ -1,4 +0,0 @@
.PHONY: run-local
run-local:
DATABASE_URL=postgres://postgres:foobarbaz@localhost:5432/postgres \
go run main.go

View File

@ -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 .

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 87 KiB