├── .gitignore ├── .dockerignore ├── config.yml ├── now.json ├── Dockerfile ├── readme.md └── LICENSE.md /.gitignore: -------------------------------------------------------------------------------- 1 | .env* 2 | # dependencies 3 | node_modules 4 | package-lock.json -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | package.json 2 | node_modules 3 | .env* 4 | package-lock.json 5 | -------------------------------------------------------------------------------- /config.yml: -------------------------------------------------------------------------------- 1 | managementApiSecret: PRISMA_MANAGEMENT_API_SECRET 2 | port: 4466 3 | databases: 4 | default: 5 | connector: mysql # or 'postgres' 6 | host: SQL_HOST 7 | port: 3306 # or '5432' for postgres 8 | user: prisma 9 | password: SQL_PASSWORD 10 | migrations: true 11 | active: true 12 | -------------------------------------------------------------------------------- /now.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prisma-now", 3 | "type": "docker", 4 | "public": false, 5 | "features": { 6 | "cloud": "v1" 7 | }, 8 | "build": { 9 | "env": { 10 | "SQL_HOST": "", 11 | "SQL_PASSWORD": "@sql-password", 12 | "PRISMA_MANAGEMENT_API_SECRET": "@prisma-management-api-secret" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Pull prisma image from dockerhub 2 | FROM prismagraphql/prisma:1.13-beta 3 | 4 | # Tell docker there are arguments we need 5 | ARG SQL_HOST 6 | ARG SQL_PASSWORD 7 | ARG PRISMA_MANAGEMENT_API_SECRET 8 | ARG PRISMA_CONFIG_PATH 9 | 10 | # Sets an server run-time environment variable to tell Prisma where to find the 11 | # server configuration. (Prisma.yml holds the Prisma config in the instance. 12 | # This is a different prisma.yml to the one 'prisma deploy' uses) 13 | ENV PRISMA_CONFIG_PATH prisma.yml 14 | 15 | # Copy over config to server 16 | COPY config.yml prisma.yml 17 | 18 | # Copy build-time environment varibles into config 19 | RUN sed -i s/SQL_HOST/$SQL_HOST/g prisma.yml 20 | RUN sed -i s/SQL_PASSWORD/$SQL_PASSWORD/g prisma.yml 21 | RUN sed -i s/PRISMA_MANAGEMENT_API_SECRET/$PRISMA_MANAGEMENT_API_SECRET/g prisma.yml 22 | 23 | # Exposes Prisma port to 80/443 i.e. :4466 is not needed at the end of the server URL 24 | EXPOSE 4466 25 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # prisma-now 2 | 3 | An example of prisma server deployment to Zeit Now with build-time environment variables. 4 | 5 | ## How to use 6 | 7 | Create now secrets for your sql and prisma api passwords: 8 | 9 | ```console 10 | > now secret add sql-password 11 | > now secret add prisma-management-api-secret 12 | ``` 13 | 14 | Amend `now.json` to point to your SQL Server: 15 | (This can be hosted anywhere, Google Cloud, AWS etc.) 16 | 17 | ```now.json 18 | ... 19 | "SQL_HOST": "" 20 | ... 21 | ``` 22 | 23 | Edit `Dockerfile`with the version of prisma you wish to deploy from [dockerhub](https://hub.docker.com/r/prismagraphql/prisma/tags/): 24 | 25 | ``` 26 | FROM prismagraphql/prisma:1.13-beta 27 | ... 28 | ``` 29 | 30 | Then you are ready to deploy! 31 | 32 | ```console 33 | > now 34 | ``` 35 | 36 | ## Extended Tutorial 37 | 38 | https://www.prisma.io/docs/tutorials/deploy-prisma-servers/zeit-now-and-google-cloud-sql-mohj5eiwot 39 | 40 | 41 | ## License 42 | This project is licensed under the MIT License - see the LICENSE.md file for details 43 | 44 | 45 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Mark Petty 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------