graphql-engine-heroku
graphql-engine-heroku copied to clipboard
Error when host hasura on heroku using Dockerfile with migrations/metadada files setup
I'm trying to deploy on Heroku Dockerfile with hasura folder with metada/migrations without success:
# FROM hasura/graphql-engine:v2.6.0
FROM hasura/graphql-engine:v2.0.4.cli-migrations-v3
COPY ./hasura/migrations /hasura-migrations
COPY ./hasura/metadata /hasura-metadata
WORKDIR /
# Enable the console
ENV HASURA_GRAPHQL_ENABLE_CONSOLE=true
# Enable debugging mode. It should be disabled in production.
ENV HASURA_GRAPHQL_DEV_MODE=true
# Heroku hobby tier PG has few limitations including 20 max connections
# https://devcenter.heroku.com/articles/heroku-postgres-plans#hobby-tier
ENV HASURA_GRAPHQL_PG_CONNECTIONS=15
CMD HASURA_GRAPHQL_METADATA_DATABASE_URL=$DATABASE_URL graphql-engine \
--database-url $DATABASE_URL \
--metadata-database-url $DATABASE_URL \
serve \
--server-port $PORT
Error:
Fatal Error: Either of --metadata-database-url or --database-url option expected
2022-04-28T21:09:06.983085+00:00 app[web.1]: {"timestamp":"2022-04-28T21:09:06.000+0000","level":"info","type":"startup","detail":{"kind":"migrations-startup","info":"failed waiting for 9691, try increasing HASURA_GRAPHQL_MIGRATIONS_SERVER_TIMEOUT (default: 30)"}}
2022-04-28T21:09:07.088317+00:00 heroku[web.1]: Process exited with status 1
2022-04-28T21:09:07.171946+00:00 heroku[web.1]: State changed from starting to crashed
structure folder:
~/Developer/popstand/graphql-engine-heroku (master) » tree -L 2 130 ↵ tgmarinho@Thiagos-MacBook-Pro
.
├── Dockerfile
├── README.md
├── app.json
├── assets
│ ├── console.png
│ ├── create_new_app_heroku.png
│ ├── create_new_app_heroku_2.png
│ ├── create_new_app_heroku_3.png
│ ├── hasura_console.png
│ ├── hasura_create_table.png
│ ├── hasura_graphql_query.png
│ ├── hasura_insert_row.png
│ ├── heroku-create-new-app.png
│ └── heroku_connect_db.png
├── hasura
│ ├── config.yaml
│ ├── metadata
│ ├── migrations
│ └── seeds
├── heroku copy.yml
└── heroku.yml
database.yaml:
- name: default
kind: postgres
configuration:
connection_info:
database_url:
# Prod: DATABASE_URL
# Dev: HASURA_GRAPHQL_DATABASE_URL
from_env: DATABASE_URL
isolation_level: read-committed
pool_settings:
connection_lifetime: 600
idle_timeout: 180
max_connections: 50
retries: 1
use_prepared_statements: true
tables: "!include default/tables/tables.yaml"
config.yaml
version: 3
# Prod: HASURA_GRAPHQL_ENDPOINT
# Dev: http://localhost:8080
endpoint: http://localhost:8080
metadata_directory: metadata
actions:
kind: synchronous
# Prod: HASURA_GRAPHQL_ENDPOINT
# Dev: http://localhost:8080
handler_webhook_baseurl: http://localhost:8080
I suggest putting some sample to Doc with migration/metadata custom hasura project
log errors:
2022-04-29T00:33:32.306313+00:00 heroku[web.1]: Starting process with command `/bin/sh -c HASURA_GRAPHQL_DATABASE_URL\=\postgres://hahha:llalal@ehahaha:5432/asdasd\ \\\ graphql-engine\ \ \ \ \ --database-url\ \postgres://[email protected]:5432/asdasda\ \ \ \ \ --metadata-database-url\ \postgres://bbsdsdsctwo:[email protected]:5432/d1vu9ahep8o5po\ \ \ \ \ serve\ \ \ \ \ --server-port\ \59490`
2022-04-29T00:33:33.492979+00:00 app[web.1]: {"timestamp":"2022-04-29T00:33:33.000+0000","level":"info","type":"startup","detail":{"kind":"migrations-startup","info":"migrations server port env var is not set, defaulting to 9691"}}
2022-04-29T00:33:33.494740+00:00 app[web.1]: {"timestamp":"2022-04-29T00:33:33.000+0000","level":"info","type":"startup","detail":{"kind":"migrations-startup","info":"starting graphql engine temporarily on port 9691"}}
2022-04-29T00:33:33.496489+00:00 app[web.1]: {"timestamp":"2022-04-29T00:33:33.000+0000","level":"info","type":"startup","detail":{"kind":"migrations-startup","info":"waiting 180 for 9691 to be ready"}}
2022-04-29T00:33:34.379510+00:00 app[web.1]: {"type":"startup","timestamp":"2022-04-29T00:33:34.374+0000","level":"info","detail":{"kind":"server_configuration","info":{"live_query_options":{"batch_size":100,"refetch_delay":1},"transaction_isolation":"ISOLATION LEVEL READ COMMITTED","enable_maintenance_mode":false,"enabled_log_types":["http-log","websocket-log","startup","webhook-log"],"server_host":"HostAny","websocket_connection_init_timeout":"WSConnectionInitTimeout {unWSConnectionInitTimeout = Seconds {seconds = 3s}}","enable_allowlist":false,"remote_schema_permissions":false,"log_level":"info","auth_hook_mode":null,"use_prepared_statements":true,"unauth_role":null,"stringify_numeric_types":false,"v1-boolean-null-collapse":false,"graceful_shutdown_timeout":60,"enabled_apis":["metadata"],"enable_telemetry":true,"enable_console":true,"auth_hook":null,"infer_function_permissions":true,"experimental_features":[],"events_fetch_batch_size":100,"jwt_secret":null,"cors_config":{"allowed_origins":"*","disabled":false,"ws_read_cookie":null},"websocket_compression_options":"NoCompression","console_assets_dir":null,"admin_secret_set":false,"port":9691,"websocket_keep_alive":"KeepAliveDelay {unKeepAliveDelay = Seconds {seconds = 5s}}"}}}
2022-04-29T00:33:34.481074+00:00 app[web.1]: {"type":"startup","timestamp":"2022-04-29T00:33:34.374+0000","level":"info","detail":{"kind":"postgres_connection","info":{"error":"parsing database url failed"}}}
2022-04-29T00:33:34.481076+00:00 app[web.1]: {"type":"pg-client","timestamp":"2022-04-29T00:33:34.374+0000","level":"warn","detail":{"message":"postgres connection failed, retrying(0)."}}
2022-04-29T00:33:34.481076+00:00 app[web.1]: {"type":"pg-client","timestamp":"2022-04-29T00:33:34.374+0000","level":"warn","detail":{"message":"postgres connection failed, retrying(1)."}}
2022-04-29T00:33:34.481080+00:00 app[web.1]: {"type":"startup","timestamp":"2022-04-29T00:33:34.374+0000","level":"error","detail":{"kind":"catalog_migrate","info":{"internal":"could not connect to server: No such file or directory\n\tIs the server running locally and accepting\n\tconnections on Unix domain socket \"/var/run/postgresql/.s.PGSQL.5432\"?\n","path":"$","error":"connection error","code":"postgres-error"}}}
2022-04-29T00:33:34.481155+00:00 app[web.1]: {"internal":"could not connect to server: No such file or directory\n\tIs the server running locally and accepting\n\tconnections on Unix domain socket \"/var/run/postgresql/.s.PGSQL.5432\"?\n","path":"$","error":"connection error","code":"postgres-error"}
Most likely the issue is providing both the --database-url
and the --metadata-database-url
flags.
Try this command instead:
CMD HASURA_GRAPHQL_METADATA_DATABASE_URL=$DATABASE_URL graphql-engine \
--metadata-database-url $DATABASE_URL \
serve \
--server-port $PORT