Skip to content

Commit

Permalink
improve testing and docs (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
aatarasoff authored Nov 8, 2023
1 parent 4922101 commit a50a78d
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 38 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.postgres-data
bin
.github

docker-compose.dev.yml
docker-compose.yml
Dockerfile

README.md
LICENSE
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Test binary, built with `go test -c`
*.test
bin/
.postgres-data/

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ FROM golang:1.21 as builder
WORKDIR /app
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o ./pbuf-migrations ./.
RUN CGO_ENABLED=0 GOOS=linux go build -o ./pbuf-registry ./cmd/...

# 2. run stage
FROM bash:alpine3.18

WORKDIR /app

COPY --from=builder /app/pbuf-migrations /app/pbuf-migrations
COPY --from=builder /app/pbuf-registry /app/pbuf-registry

CMD ["/app/pbuf-registry"]
17 changes: 0 additions & 17 deletions Dockerfile.migrations

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ docker:
.PHONY: run
# run
run:
docker-compose build --no-cache && docker-compose up --force-recreate -d
docker-compose -f docker-compose.dev.yml build --no-cache && docker-compose -f docker-compose.dev.yml up --force-recreate -d

.PHONY: stop
# stop
stop:
docker-compose down
docker-compose -f docker-compose.dev.yml down

# show help
help:
Expand Down
51 changes: 48 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,57 @@ The registry solves this problem by providing a central place to store and manag

## Installation

TBD
### Docker Compose

#### Prerequisites

- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)

#### Steps

1. Clone the repository
2. Run `docker-compose up -d`

### Helm Chart

Coming soon...

## Usage

TBD
### CLI

We recommend to use the [CLI](https://github.com/pbufio/pbuf-cli) to interact with the registry.

### API

#### HTTP

The registry provides a REST API (`:8080` port by default). You can find the swagger documentation [here](https://github.com/pbufio/pbuf-registry/blob/main/gen/v1/registry.swagger.json).

#### gRPC

The registry provides a gRPC API (`:8081` port by default). You can find the protobuf definition [here](https://github.com/pbufio/pbuf-registry/blob/main/api/v1/registry.proto)

## Development and Contributing

TBD
### Prerequisites

- [Go](https://golang.org/doc/install)
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)
- [Make](https://www.gnu.org/software/make/)

### Build

- Run `make build` to build the registry
- Run `make build-in-docker` to build linux binaries in docker

### Test

- Run `make test` to run the tests.

### Test the Registry

- Run `make run` to start the registry and test it.
- Run `make stop` to stop the running registry.
24 changes: 24 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.1'
services:
db:
image: postgres:14.7
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: pbuf
POSTGRES_PASSWORD: pbuf
POSTGRES_DB: pbuf_registry
pbuf-registry:
build:
context: .
restart: always
depends_on:
- db
ports:
- "8080:8080"
- "8081:8081"
environment:
DATA_DATABASE_DSN: "postgres://pbuf:pbuf@db:5432/pbuf_registry?sslmode=disable"
command: >
sh -c "/app/pbuf-migrations && /app/pbuf-registry"
22 changes: 6 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,21 @@ services:
restart: always
ports:
- "5432:5432"
volumes:
- ./.postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: pbuf
POSTGRES_PASSWORD: pbuf
POSTGRES_DB: pbuf_registry
pbuf-migrations:
build:
context: .
dockerfile: Dockerfile.migrations
restart: always
depends_on:
- db
environment:
DATA_DATABASE_DSN: "postgres://pbuf:pbuf@db:5432/pbuf_registry?sslmode=disable"
command:
- "/app/pbuf-migrations"
pbuf-registry:
build:
context: .
image: ghcr.io/pbufio/registry:v0.1.1
restart: always
depends_on:
- pbuf-migrations
- db
ports:
- "8080:8080"
- "8081:8081"
environment:
DATA_DATABASE_DSN: "postgres://pbuf:pbuf@db:5432/pbuf_registry?sslmode=disable"
command:
- "/app/pbuf-registry"
command: >
sh -c "/app/pbuf-migrations && /app/pbuf-registry"

0 comments on commit a50a78d

Please sign in to comment.