diff --git a/.circleci/config.yml b/.circleci/config.yml index 8edaa05..4cf0c84 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,12 @@ jobs: server: docker: - image: circleci/golang:1.12 + environment: + - POSTGRES_CONNECTION_STRING=postgres://circle:test@localhost:5432/circle_test?sslmode=disable + - image: circleci/postgres:11.2-alpine + environment: + - POSTGRES_USER=circle + - POSTGRES_PASSWORD=test working_directory: ~/offen/server steps: - checkout: @@ -17,9 +23,19 @@ jobs: paths: - /go/pkg/mod key: offen-server-{{ checksum "go.mod" }} + - run: + name: Waiting for Postgres to be ready + command: | + for i in `seq 1 10`; + do + nc -z localhost 5432 && echo Success && exit 0 + echo -n . + sleep 1 + done + echo Failed waiting for Postgres && exit 1 - run: name: Run tests - command: make test + command: make test-ci workflows: version: 2 diff --git a/README.md b/README.md index 1e495bc..9a2104c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,30 @@ Development of __offen__ has just started, so instructions are rare and things w Guidelines for running and developing the Software will be added when it makes sense to do so. Feel free to open an issue if you have a question. +### Developing the application + +#### `server` + +To work on the `server` you will need to install `docker-compose` and Go 1.12+. + +First, bootstrap the dockerized Postgres database used for development: + +``` +docker-compose run server make bootstrap +``` + +Run the server: + +``` +docker-compose up +``` + +Run the tests: + +``` +docker-compose run server make +``` + ### License MIT © [Frederik Ring](https://www.frederikring.com), [Hendrik Niefeld](http://niefeld.com/) diff --git a/docker-compose.yml b/docker-compose.yml index 04c45f3..d8104e2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,14 @@ server: - $GOPATH/pkg/mod:/go/pkg/mod environment: - GOPATH=/go + - POSTGRES_CONNECTION_STRING=postgres://postgres:develop@database:5432/postgres?sslmode=disable ports: - 8080:8080 - command: go run cmd/server/main.go + command: go run cmd/server/main.go -conn postgres://postgres:develop@database:5432/postgres?sslmode=disable + links: + - database + +database: + image: postgres:11.2 + environment: + - POSTGRES_PASSWORD=develop