Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
implement mvp, run smoke tests, update demo example
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Oct 24, 2018
1 parent be96156 commit e9abfd5
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 72 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@ Requirements:
- GNU Make 3.81 or above

```bash
$ make demo up start-migration status

Name Command State Ports
------------------------------------------------------------------------------------------------------------
guard_db_1 docker-entrypoint.sh postgres Up 5432/tcp
guard_legacy_1 docker-php-entrypoint php-fpm Up 9000/tcp
guard_migration_1 service migrate Exit 0
guard_server_1 nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
guard_service_1 service run --with-profili ... Up 80/tcp, 8090/tcp, 8091/tcp, 8092/tcp, 8093/tcp
guard_spec_1 sh /usr/share/nginx/docker ... Up 80/tcp, 8080/tcp

$ ./env/client/grpc/install.sh
$ make demo up clean status

Name Command State Ports
-----------------------------------------------------------------------------------------------------------
guard_db_1 docker-entrypoint.sh postgres Up 5432/tcp
guard_legacy_1 docker-php-entrypoint php-fpm Up 9000/tcp
guard_server_1 nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
guard_service_1 service run --with-profili ... Up 8080/tcp, 8090/tcp, 8091/tcp, 8092/tcp, 8093/tcp
guard_spec_1 sh /usr/share/nginx/docker ... Up 80/tcp, 8080/tcp

$ ./env/client/grpc/install.sh localhost:443

$ open http://spec.127.0.0.1.xip.io/

Expand Down
33 changes: 18 additions & 15 deletions env/client/grpc/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@

set -euo pipefail

export GUARD_TOKEN=10000000-2000-4000-8000-160000000003
HOST=${1:-127.0.0.1:8092}
GUARD_TOKEN=10000000-2000-4000-8000-160000000003

guardctl install -f env/client/grpc/install.yml
guardctl install -f env/client/grpc/install.yml --grpc-host=${HOST}

guardctl license register -f env/client/grpc/license.register.yml
guardctl license update -f env/client/grpc/license.update.yml
guardctl license delete -f env/client/grpc/license.delete.yml
guardctl license restore -f env/client/grpc/license.restore.yml
guardctl license read -f env/client/grpc/license.read.yml
guardctl license register -f env/client/grpc/license.register.yml --grpc-host=${HOST}
guardctl license update -f env/client/grpc/license.update.yml --grpc-host=${HOST}
guardctl license delete -f env/client/grpc/license.delete.yml --grpc-host=${HOST}
guardctl license restore -f env/client/grpc/license.restore.yml --grpc-host=${HOST}
guardctl license read -f env/client/grpc/license.read.yml --grpc-host=${HOST}

guardctl license employee add -f env/client/grpc/license.employee.yml
guardctl license employee delete -f env/client/grpc/license.employee.yml
guardctl license employee add -f env/client/grpc/license.employee.yml --grpc-host=${HOST}
guardctl license employee delete -f env/client/grpc/license.employee.yml --grpc-host=${HOST}
guardctl license employee add -f env/client/grpc/license.employee.yml --grpc-host=${HOST}

guardctl license workplace add -f env/client/grpc/license.workplace.yml
guardctl license workplace push -f env/client/grpc/license.workplace.yml
guardctl license workplace delete -f env/client/grpc/license.workplace.yml
guardctl license workplace add -f env/client/grpc/license.workplace.yml --grpc-host=${HOST}
guardctl license workplace push -f env/client/grpc/license.workplace.yml --grpc-host=${HOST}
guardctl license workplace delete -f env/client/grpc/license.workplace.yml --grpc-host=${HOST}
guardctl license workplace add -f env/client/grpc/license.workplace.yml --grpc-host=${HOST}

guardctl license create -f env/client/grpc/license.create.yml | \
guardctl license delete | \
guardctl license read
guardctl license create -f env/client/grpc/license.create.yml --grpc-host=${HOST} | \
guardctl license delete --grpc-host=${HOST} | \
guardctl license read --grpc-host=${HOST}
4 changes: 2 additions & 2 deletions env/client/grpc/license.update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ contract:
since: 2018-09-29T17:11:43.264Z
until: ~
rate: { value: 10, unit: rpd }
requests: 1000
workplaces: 10
requests: 5
workplaces: 1
17 changes: 17 additions & 0 deletions env/docker/compose/docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ services:

db:
image: guard-db:latest
build:
context: ../db/context
dockerfile: ../Dockerfile
env_file: ../db/.env

legacy:
image: guard-legacy:latest
build:
context: ../legacy/context
dockerfile: ../Dockerfile
env_file: ../legacy/.env

migration:
image: guard-service:latest
build:
args: { PACKAGE: "${PACKAGE}" }
context: ../../../.
dockerfile: ./env/docker/service/Dockerfile
command: [ "migrate" ]
depends_on:
- db
Expand All @@ -20,13 +30,20 @@ services:

service:
image: guard-service:latest
build:
args: { PACKAGE: "${PACKAGE}" }
context: ../../../.
dockerfile: ./env/docker/service/Dockerfile
command: [ "run", "--with-profiling", "--with-monitoring", "--with-grpc-gateway" ]
depends_on:
- migration
env_file: ../service/.env

server:
image: guard-server:latest
build:
context: ../server/context
dockerfile: ../Dockerfile
depends_on:
- legacy
- service
Expand Down
12 changes: 1 addition & 11 deletions env/docker/compose/docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
version: "3"

services:

db: {}

legacy: {}

migration: {}

service: {}

server: {}
services: {}
6 changes: 0 additions & 6 deletions env/docker/compose/docker-compose.demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ services:
volumes:
- pgdata:${PGDATA}

legacy: {}

migration: {}

service: {}

server:
depends_on:
- spec
Expand Down
21 changes: 0 additions & 21 deletions env/docker/compose/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,12 @@ version: "3"
services:

db:
build:
context: ../db/context
dockerfile: ../Dockerfile
ports:
- ${LOCAL_DB_PORT}:5432
volumes:
- pgdata:${PGDATA}

legacy:
build:
context: ../legacy/context
dockerfile: ../Dockerfile

migration:
build:
args: { PACKAGE: "${PACKAGE}" }
context: ../../../.
dockerfile: ./env/docker/service/Dockerfile

service:
build:
args: { PACKAGE: "${PACKAGE}" }
context: ../../../.
dockerfile: ./env/docker/service/Dockerfile
ports:
- ${LOCAL_SERVICE_HTTP_PORT}:8080
- ${LOCAL_SERVICE_PROFILING_PORT}:8090
Expand All @@ -35,9 +17,6 @@ services:
- ${LOCAL_SERVICE_GRPC_GATEWAY_PORT}:8093

server:
build:
context: ../server/context
dockerfile: ../Dockerfile
ports:
- ${LOCAL_SERVER_HTTP_PORT}:80
- ${LOCAL_SERVER_HTTPS_PORT}:443
Expand Down
2 changes: 1 addition & 1 deletion env/docker/server/context/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ server {
# documentation
# - https://www.nginx.com/blog/nginx-1-13-10-grpc/
# - https://nginx.org/en/docs/http/ngx_http_grpc_module.html
location /grpc { grpc_pass grpc://service_grpc; }
location /protobuf { grpc_pass grpc://service_grpc; }

location /guard/api/ {
rewrite ^/guard/api/(.*) /api/$1 break;
Expand Down
8 changes: 4 additions & 4 deletions env/docker/service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ ENV GOARCH amd64
ENV CGO_ENABLED 0

RUN echo "os: ${GOOS}" "arch: ${GOARCH}" "cgo: ${CGO_ENABLED}" \
&& export _commit="-X ${PACKAGE}/cmd.commit=$(git rev-parse --short HEAD || echo 'none')" \
&& export _date="-X ${PACKAGE}/cmd.date=$(date -u +%FT%X%Z || echo 'unknown')" \
&& export _version="-X ${PACKAGE}/cmd.version=$(git describe --tags 2>&- || echo 'dev' | cut -d - -f 1)" \
&& export _commit="-X ${PACKAGE}/pkg/cmd.commit=$(git rev-parse --short HEAD || echo 'none')" \
&& export _date="-X ${PACKAGE}/pkg/cmd.date=$(date -u +%FT%X%Z || echo 'unknown')" \
&& export _version="-X ${PACKAGE}/pkg/cmd.version=$(git describe --tags 2>&- || echo 'dev' | cut -d - -f 1)" \
&& go build -o /go/bin/service \
-ldflags "-s -w ${_commit} ${_date} ${_version}" .
-ldflags "-s -w ${_commit} ${_date} ${_version}" ./cmd/guard


FROM alpine:latest AS service
Expand Down

0 comments on commit e9abfd5

Please sign in to comment.