Updated readme and stuff
This commit is contained in:
parent
795222f342
commit
113c177bdc
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.17.5-alpine3.14 AS builder
|
||||
FROM golang:1.17.6-alpine3.14 AS builder
|
||||
|
||||
# Install missing pkgs
|
||||
RUN apk add --no-cache git
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
FROM amacneil/dbmate:v1.12.1
|
||||
|
||||
COPY ./db ./db
|
||||
|
||||
CMD ["--wait", "up"]
|
24
README.md
24
README.md
|
@ -6,25 +6,9 @@ A tiny REST API for auth. Register accounts, auth with api-key or name/password,
|
|||
|
||||
Migrate database: `docker-compose run --rm db-migrations`
|
||||
|
||||
(Optional) Run tests: `docker-compose run --rm tests`
|
||||
Start the API (on port 4000 by default): `docker-compose up -d`
|
||||
|
||||
Start the service (on port 4000 by default): `docker-compose up -d` (db migrations must be ran before this)
|
||||
|
||||
## Databaes migration
|
||||
|
||||
Done using [dbmate](https://github.com/amacneil/dbmate). Db stuff is stored in `./db`.
|
||||
|
||||
Example of running the migrations:
|
||||
|
||||
`docker run --rm -it -e DATABASE_URL="postgres://postgres:postgres@127.0.0.1:5432/auth?sslmode=disable" --network=host -v "$(pwd)/db:/db" amacneil/dbmate up`
|
||||
|
||||
Example of setting up a postgres SQL server:
|
||||
|
||||
`docker run -d --name postgres --network=host -e POSTGRES_PASSWORD=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=auth postgres`
|
||||
|
||||
If you are on of those poor people runnin macOS you must use this one to start a postgres server :(
|
||||
|
||||
`docker run -d --name pwrpln-postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=auth postgres`
|
||||
Point your browser to `http://localhost:4000` to view the swagger API documentation.
|
||||
|
||||
## Admin account
|
||||
|
||||
|
@ -34,6 +18,10 @@ On first startup with a clean database, an account with name "admin" and the fie
|
|||
|
||||
The account field "role" is a bit special, in that if it contains "admin" as one of its values, that grants access to all methods on all accounts on this service. It might be a good idea to use the field "role" for authorization throughout your services.
|
||||
|
||||
## Tests
|
||||
|
||||
Run integration tests (Requires migrated database and started API): `docker-compose run --rm tests`
|
||||
|
||||
## Some useful cURLs
|
||||
|
||||
Obtain an admin GWT: `curl -d '"api-key-goes-here"' -H "Content-Type: application/json" -i http://localhost:4000/auth/api-key`
|
||||
|
|
|
@ -11,15 +11,12 @@ services:
|
|||
- 5432:5432
|
||||
|
||||
db-migrations:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.db
|
||||
#image: amacneil/dbmate:v1.12.1
|
||||
image: amacneil/dbmate:v1.12.1
|
||||
environment:
|
||||
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/auth?sslmode=disable
|
||||
volumes:
|
||||
- "./db:/db:ro"
|
||||
command: --wait up
|
||||
command: ["--wait", "up"]
|
||||
profiles: ["migrations"]
|
||||
depends_on:
|
||||
- postgres
|
||||
|
|
Loading…
Reference in New Issue
Block a user