Skip to content

Commit

Permalink
Simplify bundle (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
maorfr authored Apr 2, 2019
1 parent 8e538a4 commit 3d8f333
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
dist/*
node_modules/*
bundle/*
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
.PHONY: build push
.PHONY: bundle build push

IMAGE_NAME := quay.io/app-sre/qontract-server
IMAGE_TAG := $(shell git rev-parse --short=7 HEAD)
APP_INTERFACE_PATH ?= $(shell pwd)/../../service/app-interface
SCHEMAS_DIR := $(APP_INTERFACE_PATH)/schemas
GRAPHQL_SCHEMA_DIR := $(APP_INTERFACE_PATH)/graphql-schemas
DATA_DIR := $(APP_INTERFACE_PATH)/data
RESOURCES_DIR := $(APP_INTERFACE_PATH)/resources
BUNDLE_DIR := $(shell pwd)/bundle
BUNDLE_FILENAME := bundle.json
VALIDATOR_IMAGE_NAME ?= quay.io/app-sre/qontract-validator
VALIDATOR_IMAGE_TAG ?= latest

ifneq (,$(wildcard $(CURDIR)/.docker))
DOCKER_CONF := $(CURDIR)/.docker
else
DOCKER_CONF := $(HOME)/.docker
endif

bundle:
@docker pull $(VALIDATOR_IMAGE_NAME):$(VALIDATOR_IMAGE_TAG)
mkdir -p $(BUNDLE_DIR)
@docker run --rm \
-v $(SCHEMAS_DIR):/schemas:z \
-v $(GRAPHQL_SCHEMA_DIR):/graphql:z \
-v $(DATA_DIR):/data:z \
-v $(RESOURCES_DIR):/resources:z \
$(VALIDATOR_IMAGE_NAME):$(VALIDATOR_IMAGE_TAG) \
qontract-bundler /schemas /graphql/schema.yml /data /resources > $(BUNDLE_DIR)/$(BUNDLE_FILENAME)
@docker run --rm \
-v $(BUNDLE_DIR):/bundle:z \
$(VALIDATOR_IMAGE_NAME):$(VALIDATOR_IMAGE_TAG) \
qontract-validator --only-errors /bundle/$(BUNDLE_FILENAME)

run:
LOAD_METHOD=fs DATAFILES_FILE=$(BUNDLE_DIR)/$(BUNDLE_FILENAME) yarn run server

build:
@docker build -t $(IMAGE_NAME):latest .
@docker tag $(IMAGE_NAME):latest $(IMAGE_NAME):$(IMAGE_TAG)
Expand Down
27 changes: 5 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,17 @@ yarn install
yarn build

# Start the server
LOAD_METHOD=fs DATAFILES_FILE=<data-bundle-json> yarn run server
make run
```
## Creating the schema, data and resources bundle
## Creating and validating the bundle

The bundles are required to run the validation and to start the server.
The bundle is required to start the server.

```sh
mkdir -p $BUNDLES_DIR
docker run --rm \
-v $SCHEMAS_DIR:/schemas:z \
-v $GRAPHQL_SCHEMA_DIR:/graphql:z \
-v $DATA_DIR:/data:z \
-v $RESOURCES_DIR:/resources:z \
quay.io/app-sre/qontract-validator:latest \
qontract-bundler /schemas /graphql/schema.yml /data /resources > $BUNDLES_DIR/bundle.json
make bundle
```

* `SCHEMAS_DIR` - dir that contains the JSON schemas (this is not used by this server).
* `GRAPHQL_SCHEMA_DIR` - dir that contains the file `schema.yml` representing the GraphQL schema.
* `DATA_DIR` - dir that contains the datafiles.
* `RESOURCES_DIR` - dir that contains the resources.
* `$BUNDLES_DIR` - a directory that will contain the created `bundle.json` file.

## Validating the bundle

```sh
docker run --rm -v $BUNDLES_DIR:/bundle:z quay.io/app-sre/qontract-validator:latest qontract-validator --only-errors /bundle/bundle.json
```
* `APP_INTERFACE_PATH` - (optional) path to a local app-interface repo (Default: `$PWD/../../service/app-interface`).

## Style

Expand Down

0 comments on commit 3d8f333

Please sign in to comment.