├── .mysql.env ├── .prisma.env ├── docker-compose.yml └── readme.md /.mysql.env: -------------------------------------------------------------------------------- 1 | MYSQL_ROOT_PASSWORD=prisma -------------------------------------------------------------------------------- /.prisma.env: -------------------------------------------------------------------------------- 1 | PORT=4466 2 | SQL_CLIENT_HOST_CLIENT1=database 3 | SQL_CLIENT_HOST_READONLY_CLIENT1=database 4 | SQL_CLIENT_HOST=database 5 | SQL_CLIENT_PORT=3306 6 | SQL_CLIENT_USER=root 7 | SQL_CLIENT_PASSWORD=prisma 8 | SQL_CLIENT_CONNECTION_LIMIT=10 9 | SQL_INTERNAL_HOST=database 10 | SQL_INTERNAL_PORT=3306 11 | SQL_INTERNAL_USER=root 12 | SQL_INTERNAL_PASSWORD=prisma 13 | SQL_INTERNAL_DATABASE=graphcool 14 | CLUSTER_ADDRESS=http://prisma:4466 15 | SQL_INTERNAL_CONNECTION_LIMIT=10 16 | SCHEMA_MANAGER_SECRET=graphcool 17 | SCHEMA_MANAGER_ENDPOINT=http://prisma:4466/cluster/schema 18 | #CLUSTER_PUBLIC_KEY= 19 | BUGSNAG_API_KEY="" 20 | ENABLE_METRICS=0 21 | JAVA_OPTS=-Xmx1G 22 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | database: 5 | image: 'mysql:5.7' 6 | container_name: 'mysql' 7 | restart: 'always' 8 | command: 'mysqld --max-connections=1000 --sql-mode="ALLOW_INVALID_DATES,ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO,HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,PIPES_AS_CONCAT,REAL_AS_FLOAT,STRICT_ALL_TABLES,STRICT_TRANS_TABLES,ANSI,DB2,MAXDB,MSSQL,MYSQL323,MYSQL40,ORACLE,POSTGRESQL,TRADITIONAL"' 9 | networks: 10 | - 'prisma' 11 | env_file: './.mysql.env' 12 | ports: 13 | - '3306:3306' 14 | volumes: 15 | - 'volume-database:/var/lib/mysql' 16 | 17 | prisma: 18 | image: 'prismagraphql/prisma:1.3-beta' 19 | container_name: "prisma" 20 | restart: 'always' 21 | ports: 22 | - '0.0.0.0:4466:4466' 23 | depends_on: 24 | - 'database' 25 | networks: 26 | - 'prisma' 27 | env_file: './.prisma.env' 28 | 29 | networks: 30 | prisma: 31 | driver: "bridge" 32 | 33 | volumes: 34 | volume-database: -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Prisma: Docker Compose setup 2 | 3 | This repository demonstrates how to start a Prisma cluster (MySQL + Prisma) via Docker Compose. 4 | 5 | ## Usage 6 | 7 | ``` 8 | git clone git@github.com:akoenig/prisma-docker-compose.git && cd prisma-docker-compose 9 | 10 | docker-compose up 11 | ``` 12 | 13 | **Important:** You might see the following exception from the Prisma container on the first run: 14 | 15 | ``` 16 | Exception in thread "main" java.sql.SQLTransientConnectionException: internalRoot - Connection is not available, request timed out after 5001ms. 17 | prisma | at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:548) 18 | prisma | at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:186) 19 | prisma | at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:145) 20 | prisma | at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:83) 21 | ... 22 | ``` 23 | 24 | This happens when your MySQL instance takes longer to boot than the Prisma server. In this case you only have to wait for a container rescheduling by the Docker engine. The Prisma container will be started after a while and you should see this output then: 25 | 26 | ``` 27 | prisma | Obtaining exclusive agent lock... 28 | prisma | Obtaining exclusive agent lock... Successful. 29 | prisma | Deployment worker initialization complete. 30 | prisma | Initializing workers... 31 | prisma | Successfully started 1 workers. 32 | prisma | Server running on :4466 33 | prisma | Version is up to date. 34 | ``` 35 | 36 | The cluster comes with a [GraphQL Playground](https://github.com/graphcool/graphql-playground) at http://localhost:4466/cluster – Here you can obtain cluster information like the deployed projects, etc. For example: 37 | 38 | ```graphql 39 | { 40 | listProjects { 41 | name 42 | } 43 | } 44 | ``` 45 | 46 | ## Configuration 47 | 48 | You can find two separate `env` files in this repository: `.mysql.env` and `.prisma.env`. Each of them is attached to the respective container via `env_file` in the `docker-compose.yml`. 49 | 50 | ## Connecting to the cluster via `Prisma CLI` 51 | 52 | The central place for configuring your Prisma CLI is the file `~/.prisma/config.yml`. You can add your new cluster to this file by executing `prisma cluster add`: 53 | 54 | ``` 55 | ❯ prisma cluster add 56 | ? Please provide the cluster endpoint http://localhost:4466 57 | ? Please provide the cluster secret 58 | ? Please provide a name for your cluster myprismacluster 59 | ``` 60 | 61 | **Important:** Leave `cluster secret` empty. This is because we haven't configured the `CLUSTER_PUBLIC_KEY` in `.prisma.env`. Please note that this is only for development purposes. You have to generate a key pair for securing your cluster if you want to create a production environment. You can find more information about how to secure your cluster in the [docs](). Your `cluster secret` would then the generated `private` key, whereas the public key has to be placed as `CLUSTER_PUBLIC_KEY` in `.prisma.env`. 62 | 63 | If you used one of the boilerplates, like [typescript-graphql-server](https://github.com/graphql-boilerplates/typescript-graphql-server), you have to configure the `.env` file in there as follows: 64 | 65 | ``` 66 | ... 67 | PRISMA_ENDPOINT="http://localhost:4466//dev" 68 | PRISMA_CLUSTER="myprismacluster" 69 | ... 70 | ``` 71 | 72 | Afterwards, you can deploy the schema via `prisma deploy`. 73 | 74 | ## License 75 | 76 | MIT © [André König](https://andrekoenig.de) 77 | --------------------------------------------------------------------------------