diff --git a/.ciignore b/.ciignore index 3002f54af4523..cc6f2219b6f4a 100644 --- a/.ciignore +++ b/.ciignore @@ -4,6 +4,7 @@ scripts/* assets/* docs/* community/* +install-manifests/* .circleci/* .ciignore .gitignore diff --git a/.circleci/deploy.sh b/.circleci/deploy.sh index d70b9d7127f2f..0d0e97ae2d530 100755 --- a/.circleci/deploy.sh +++ b/.circleci/deploy.sh @@ -104,6 +104,5 @@ if [[ ! -z "$CIRCLE_TAG" ]]; then deploy_server_latest draft_github_release configure_git - send_pr_to_repo graphql-engine-install-manifests send_pr_to_repo graphql-engine-heroku fi diff --git a/README.md b/README.md index 16984eac64d9d..b13c57aaeb638 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,9 @@ The fastest way to try Hasura out is via Heroku. ### Other deployment methods -For Docker-based deployment and advanced configuration options, see [deployment guides](https://docs.hasura.io/1.0/graphql/manual/getting-started/index.html). +For Docker-based deployment and advanced configuration options, see [deployment +guides](https://docs.hasura.io/1.0/graphql/manual/getting-started/index.html) or +[install manifests](install-manifests). ## Architecture @@ -165,7 +167,7 @@ written more about what you can and cannot do under AGPL SLAs are available on request. Please feel free to contact us at build@hasura.io or on our [website chat](https://hasura.io). -All **other contents** (except those in [`server`](server), [`cli`](cli) and +All **other content** (except those in [`server`](server), [`cli`](cli) and [`console`](console) directories) are under [MIT License](LICENSE-community). This includes everything in the [`docs`](docs) and [`community`](community) directories. diff --git a/cli/CONTRIBUTING.md b/cli/CONTRIBUTING.md index b98a1f3c7bae6..7d5c856eebee7 100644 --- a/cli/CONTRIBUTING.md +++ b/cli/CONTRIBUTING.md @@ -45,9 +45,16 @@ already be in your `PATH`. The config is located at `.realize/realize.yaml`. ## Tests -When you're adding a new feature, it is encouraged to add integration tests (unit tests also if possible) for the functions/api. You should run all the test and make sure everything passes before submitting the PR. - -The tests expect a GraphQL Engine server instance to be running. You can point the tests to any GraphQL Engine server but please note that **the database should be empty**. The easiest way to do this is to run an Postgres and GraphQL Engine using [Docker Compose](https://github.com/hasura/graphql-engine-install-manifests). Once the server is running, you can run the tests by executing the make command: +When you're adding a new feature, it is encouraged to add integration tests +(unit tests also if possible) for the functions/api. You should run all the test +and make sure everything passes before submitting the PR. + +The tests expect a GraphQL Engine server instance to be running. You can point +the tests to any GraphQL Engine server but please note that **the database +should be empty**. The easiest way to do this is to run an Postgres and GraphQL +Engine using [Docker +Compose](https://github.com/hasura/graphql-engine/tree/master/install-manifests). +Once the server is running, you can run the tests by executing the make command: ```bash HASURA_GRAPHQL_TEST_ENDPOINT=http://localhost:8080 VERSION=dev make test diff --git a/docs/LICENSE b/docs/LICENSE deleted file mode 100644 index ba646e0fa6fb6..0000000000000 --- a/docs/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Hasura Technologies Private Limited. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/docs/README.md b/docs/README.md index a4f7328759c04..27080f0d5ad3b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,4 +10,4 @@ Checkout the [contributing](CONTRIBUTING.md) guide for more details. ## License -The source code in this directory are under [MIT License](LICENSE-community). +The source code in this directory are under [MIT License](../LICENSE-community). diff --git a/docs/graphql/manual/deployment/docker/index.rst b/docs/graphql/manual/deployment/docker/index.rst index aa9ebecc62b2e..66e1c7db52df4 100644 --- a/docs/graphql/manual/deployment/docker/index.rst +++ b/docs/graphql/manual/deployment/docker/index.rst @@ -12,12 +12,12 @@ and connect it to your Postgres database. Step 1: Get the docker run bash script -------------------------------------- -The `hasura/graphql-engine-install-manifests `_ repo +The `hasura/graphql-engine/install-manifests `_ repo contains all installation manifests required to deploy Hasura anywhere. Get the docker run bash script from there: .. code-block:: bash - $ wget https://raw.githubusercontent.com/hasura/graphql-engine-install-manifests/master/docker-run/docker-run.sh + $ wget https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/docker-run/docker-run.sh Step 2: Run the hasura docker container --------------------------------------- diff --git a/docs/graphql/manual/deployment/kubernetes/index.rst b/docs/graphql/manual/deployment/kubernetes/index.rst index 968031ad280c0..2357ca7e94268 100644 --- a/docs/graphql/manual/deployment/kubernetes/index.rst +++ b/docs/graphql/manual/deployment/kubernetes/index.rst @@ -8,14 +8,14 @@ and connect it to your Postgres database. Step 1: Get the Kubernetes deployment and service files ------------------------------------------------------- -The `hasura/graphql-engine-install-manifests `_ repo +The `hasura/graphql-engine/install-manifests `_ repo contains all installation manifests required to deploy Hasura anywhere. Get the Kubernetes deployment and service files from there: .. code-block:: bash - $ wget https://raw.githubusercontent.com/hasura/graphql-engine-install-manifests/master/kubernetes/deployment.yaml - $ wget https://raw.githubusercontent.com/hasura/graphql-engine-install-manifests/master/kubernetes/svc.yaml + $ wget https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/kubernetes/deployment.yaml + $ wget https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/kubernetes/svc.yaml Step 2: Set the Postgres database url ------------------------------------- diff --git a/docs/graphql/manual/getting-started/docker-simple.rst b/docs/graphql/manual/getting-started/docker-simple.rst index 81cf44061face..680eba19f1217 100644 --- a/docs/graphql/manual/getting-started/docker-simple.rst +++ b/docs/graphql/manual/getting-started/docker-simple.rst @@ -17,13 +17,13 @@ guide to :doc:`deploy the Hasura GraphQL engine as a standalone docker container Step 1: Get the docker-compose file ----------------------------------- -The `hasura/graphql-engine-install-manifests `_ repo +The `hasura/graphql-engine/install-manifests `_ repo contains all installation manifests required to deploy Hasura anywhere. Get the docker compose file from there: .. code-block:: bash # in a new directory - wget https://raw.githubusercontent.com/hasura/graphql-engine-install-manifests/master/docker-compose/docker-compose.yaml + wget https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/docker-compose/docker-compose.yaml Step 2: Run Hasura GraphQL engine & Postgres -------------------------------------------- diff --git a/install-manifests/README.md b/install-manifests/README.md new file mode 100644 index 0000000000000..7969953783a12 --- /dev/null +++ b/install-manifests/README.md @@ -0,0 +1,13 @@ +# Hasura GraphQL Engine Installation Manifests + +Various installation / deployment methods for Hasura GraphQL Engine + +1. [Docker Compose](docker-compose) +2. [Docker Compose with HTTPS using Caddy](docker-compose-https) +3. [Docker run](docker-run) +3. [Kubernetes](kubernetes) + + +## License + +All content in this directory is under [MIT License](../LICENSE-community). diff --git a/install-manifests/docker-compose-https/Caddyfile b/install-manifests/docker-compose-https/Caddyfile new file mode 100644 index 0000000000000..b842b37f409ee --- /dev/null +++ b/install-manifests/docker-compose-https/Caddyfile @@ -0,0 +1,5 @@ + { + proxy / graphql-engine:8080 { + websocket + } +} diff --git a/install-manifests/docker-compose-https/README.md b/install-manifests/docker-compose-https/README.md new file mode 100644 index 0000000000000..9a288959e2ba2 --- /dev/null +++ b/install-manifests/docker-compose-https/README.md @@ -0,0 +1,27 @@ +# Hasura GraphQL Engine on Docker with HTTPS + +This Docker Compose setup runs [Hasura GraphQL Engine](https://github.com/hasura/graphql-engine) with [Caddy](https://caddyserver.com) webserver and automatic HTTPS certs from [LetsEncrypt](https://letsencrypt.org/). + +## Pre-requisites + +- [Docker](https://docs.docker.com/install/) +- [Docker Compose](https://docs.docker.com/compose/install/) + +## Usage + +- Clone this repo on a machine with a public ip address +- Map your domain name to this ip address +- Edit `Caddyfile` and add your domain (replace `` with your domain, don't keep `<>`) +- Edit `docker-compose.yaml` and change `HASURA_GRAPHQL_ACCESS_KEY` to something secure +- `docker-compose up -d` + +GraphQL endpoint will be `https:///v1alpha1/graphql` +Console will be available on `https:///console` + +## Connecting to External Postgres + +If you want to connect to an external/existing postgres database, replace `HASURA_GRAPHQL_DATABASE_URL` in `docker-compose.yaml` with your database url. + +**Note: localhost will resolve to the container ip inside a docker container, not the host ip** + + diff --git a/install-manifests/docker-compose-https/docker-compose.yaml b/install-manifests/docker-compose-https/docker-compose.yaml new file mode 100644 index 0000000000000..492b12763f4bd --- /dev/null +++ b/install-manifests/docker-compose-https/docker-compose.yaml @@ -0,0 +1,33 @@ +version: '3.6' +services: + postgres: + image: postgres + restart: always + volumes: + - db_data:/var/lib/postgresql/data + graphql-engine: + image: hasura/graphql-engine:v1.0.0-alpha18 + depends_on: + - "postgres" + restart: always + environment: + HASURA_GRAPHQL_ACCESS_KEY: mysecretaccesskey + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:@postgres:5432/postgres + command: + - graphql-engine + - serve + - --enable-console + caddy: + image: abiosoft/caddy + depends_on: + - "graphql-engine" + restart: always + ports: + - "80:80" + - "443:443" + volumes: + - ./Caddyfile:/etc/Caddyfile + - caddy_certs:/root/.caddy +volumes: + db_data: + caddy_certs: diff --git a/install-manifests/docker-compose/README.md b/install-manifests/docker-compose/README.md new file mode 100644 index 0000000000000..8e3de768f17cb --- /dev/null +++ b/install-manifests/docker-compose/README.md @@ -0,0 +1,24 @@ +# Hasura GraphQL Engine on Docker + +This Docker Compose setup runs [Hasura GraphQL Engine](https://github.com/hasura/graphql-engine) along with Postgres using `docker-compose`. + +## Pre-requisites + +- [Docker](https://docs.docker.com/install/) +- [Docker Compose](https://docs.docker.com/compose/install/) + +## Usage + +- Clone this repo on a machine where you'd like to deploy graphql engine +- `docker-compose up -d` + +GraphQL endpoint will be `https:///v1alpha1/graphql` +Console will be available on `https:///console` + +## Connecting to External Postgres + +If you want to connect to an external/existing postgres database, replace `HASURA_GRAPHQL_DATABASE_URL` in `docker-compose.yaml` with your database url. + +**Note: localhost will resolve to the container ip inside a docker container, not the host ip** + + diff --git a/install-manifests/docker-compose/docker-compose.yaml b/install-manifests/docker-compose/docker-compose.yaml new file mode 100644 index 0000000000000..c3841525b17c0 --- /dev/null +++ b/install-manifests/docker-compose/docker-compose.yaml @@ -0,0 +1,22 @@ +version: '3.6' +services: + postgres: + image: postgres + restart: always + volumes: + - db_data:/var/lib/postgresql/data + graphql-engine: + image: hasura/graphql-engine:v1.0.0-alpha18 + ports: + - "8080:8080" + depends_on: + - "postgres" + restart: always + environment: + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:@postgres:5432/postgres + command: + - graphql-engine + - serve + - --enable-console +volumes: + db_data: diff --git a/install-manifests/docker-run/docker-run.sh b/install-manifests/docker-run/docker-run.sh new file mode 100755 index 0000000000000..f6f6add19eb1f --- /dev/null +++ b/install-manifests/docker-run/docker-run.sh @@ -0,0 +1,6 @@ +#! /bin/bash +docker run -d -p 8080:8080 \ + hasura/graphql-engine:v1.0.0-alpha18 \ + graphql-engine \ + --database-url postgres://username:password@hostname:port/dbname \ + serve --enable-console diff --git a/install-manifests/kubernetes/README.md b/install-manifests/kubernetes/README.md new file mode 100644 index 0000000000000..576e8dd8a8815 --- /dev/null +++ b/install-manifests/kubernetes/README.md @@ -0,0 +1,33 @@ +# Deploy Hasura GraphQL engine on Kubernetes + +### Step 1: Edit deployment.yaml and set the right database url + +```yaml +... + env: + - name: HASURA_GRAPHQL_DATABASE_URL + value: postgres://username:password@hostname:port/dbname +... +``` + +### Step 2: Create the kubernetes deployment, service + +``` +kubectl create -f deployment.yaml +kubectl create -f svc.yaml +``` + +### Step 3: Access the console +This creates a LoadBalancer type service with port 80. So you should be able to +access the console at the external IP. + +For example, using docker-for-desktop on mac: + +``` +$ kubectl get svc +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +hasura LoadBalancer 10.96.214.240 localhost 80:30303/TCP 4m +kubernetes ClusterIP 10.96.0.1 443/TCP 8m +``` + +Head to: `http://localhost` and the console should load! diff --git a/install-manifests/kubernetes/deployment.yaml b/install-manifests/kubernetes/deployment.yaml new file mode 100644 index 0000000000000..249b2c12dd164 --- /dev/null +++ b/install-manifests/kubernetes/deployment.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: hasura + hasuraService: custom + name: hasura + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: hasura + template: + metadata: + creationTimestamp: null + labels: + app: hasura + spec: + containers: + - image: hasura/graphql-engine:v1.0.0-alpha18 + imagePullPolicy: IfNotPresent + name: hasura + command: ["graphql-engine"] + args: ["serve", "--enable-console"] + env: + - name: HASURA_GRAPHQL_DATABASE_URL + value: postgres://username:password@hostname:port/dbname + ports: + - containerPort: 8080 + protocol: TCP + resources: {} diff --git a/install-manifests/kubernetes/svc.yaml b/install-manifests/kubernetes/svc.yaml new file mode 100644 index 0000000000000..8412ffe8d531e --- /dev/null +++ b/install-manifests/kubernetes/svc.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: hasura + name: hasura + namespace: default +spec: + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + selector: + app: hasura + type: LoadBalancer diff --git a/scripts/tag-release.sh b/scripts/tag-release.sh new file mode 100755 index 0000000000000..ebee0215c1978 --- /dev/null +++ b/scripts/tag-release.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# +# tag-release.sh +# +# Update installation manifests with the release tag, and execute other release +# hygiene tasks, makes a commit and tags that commit with the given tag. +# +# Usage: ./tag-release.sh [] +# +# Example: ./tag-release.sh v1.1.0 +# + +# exit on error +set -e + +# get the repo root +ROOT="$(readlink -f ${BASH_SOURCE[0]%/*}/../)" + +# check if required argument is set +if [ -z "$1" ]; then + echo "Usage: ./tag-release.sh []" + exit 1 +fi + +# assign arguments to variables +TAG=$1 +MESSAGE=$2 + +# default message to tag +if [ -z "$MESSAGE" ]; then + MESSAGE="$TAG" +fi + +# replace the image version with latest tag for all references in install-manifests +find "$ROOT/install-manifests" -type f -exec sed -i -E 's#(hasura/graphql-engine:)v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?( \\)*$#\1'"${TAG}"'\9#' {} \; + +git add "$ROOT/install-manifests" +git commit -m "update installation manifests to $TAG" + +git tag -a "$TAG" -m "$MESSAGE" + +echo "tagged $TAG"