Merge branch 'master' into gRPC-endpoints

This commit is contained in:
itsscb 2023-10-07 01:59:44 +02:00
commit 94a68a6db1
2 changed files with 21 additions and 24 deletions

View File

@ -1,18 +1,18 @@
DB_URL=postgresql://root:secret@localhost:5432/df?sslmode=disable DB_URL=postgresql://root:secret@localhost:5432/df?sslmode=disable
reset_docker: reset_docker:
docker rm -vf df -docker rm -vf df
docker rmi -f df -docker rmi -f df
docker rm -vf postgres -docker rm -vf postgres
docker rmi -f postgres -docker rmi -f postgres
docker rm -vf migrate -docker rm -vf migrate
backend_build: backend_build:
make network make network;
make postgres make postgres;
docker rm -vf df -docker rm -vf df;
docker rmi -f df:latest -docker rmi -f df:latest;
docker rmi -f docker.io/library/golang:1.21-alpine3.18 -docker rmi -f docker.io/library/golang:1.21-alpine3.18
docker build -t df:latest -f bff/Dockerfile docker build -t df:latest -f bff/Dockerfile
docker exec -it postgres createdb --username=root --owner=root df docker exec -it postgres createdb --username=root --owner=root df
docker run --name migrateup --rm --privileged=true -v $(PWD)/bff/db/migration:/migrations --network host migrate/migrate -path=/migrations/ -database $(DB_URL) up docker run --name migrateup --rm --privileged=true -v $(PWD)/bff/db/migration:/migrations --network host migrate/migrate -path=/migrations/ -database $(DB_URL) up
@ -30,7 +30,7 @@ dev:
make migrateup make migrateup
network: network:
docker network create df-network -docker network create df-network
postgres: postgres:
docker start postgres || docker run --name postgres -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret --network df-network -d postgres:15-alpine docker start postgres || docker run --name postgres -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret --network df-network -d postgres:15-alpine

View File

@ -3,18 +3,16 @@
To first run the application in your local environment you can use To first run the application in your local environment you can use
``` ```
# First: (re-)build the app image including migration # In the root directory
make backend_build docker-compose -f ./bff/docker-compose.yaml -p df-bff up -d
# In bff directory
docker-compose -p df-bff up -d
# Second: run the db and the app as docker containers # Using `make`
make backend make backend
``` ```
or run those commands, listed in ```Makefile```, ***manually*** with your terminal in the repository root directory.
**Important**: The docker commands were tested on *fedora*. On *Windows* some commands might differ or do not work at all. E. g. `make migrateup`.
That is due to the fact that on *Windows* the parameters `--privileged=true` and `--network host` do not exist or are handled differently.
# Prerequisites # Prerequisites
To create a local development environment you need some tools. To create a local development environment you need some tools.
@ -74,11 +72,10 @@ Should you want to make changes you need further tools.
- [evans](https://github.com/ktr0731/evans): For testing gRPC endpoints - [evans](https://github.com/ktr0731/evans): For testing gRPC endpoints
- [protoc](https://grpc.io/docs/protoc-installation/): For generating code from `.proto`-files (gRPC) - [protoc](https://grpc.io/docs/protoc-installation/): For generating code from `.proto`-files (gRPC)
- *plugins*:``` - *plugins*:```
go install \ go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \ go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
google.golang.org/protobuf/cmd/protoc-gen-go \ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
google.golang.org/grpc/cmd/protoc-gen-go-grpc
``` ```
**Important**: If you install `protoc` on *fedora* you will need an additional package to make it work. Use the following command for setup: **Important**: If you install `protoc` on *fedora* you will need an additional package to make it work. Use the following command for setup: