安装前提条件:
1、已经安装了docker运行环境
2、以下命令执行记录发生在MackBook环境
3、已经安装了PostgreSQL(我使用的是11版本)
4、Node开发运行环境可以正常工作
 
首先需要通过Node包管理器安装Prisma工具:
 
npm install -g prisma
 
然后,创建并初始化prisma项目:
 
prisma init prisma-study
 
? Set up a new Prisma server or deploy to an existing server? (Use arrow keys)
                        
  You can set up Prisma for local development (based on docker-compose)
❯ Use existing database      Connect to existing database
  Create new database        Set up a local database using Docker
                        
  Or deploy to an existing Prisma server:
  Demo server                Hosted demo environment incl. database (requires login)
  Use other server           Manually provide endpoint of a running Prisma server
 
选择使用已存在的数据库(Use existing database)后,回车确认选择。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to?
  MySQL             MySQL compliant databases like MySQL or MariaDB
❯ PostgreSQL        PostgreSQL database
 
移动上下箭头键盘按键,选择PostgreSQL后,再次回车确认选择。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? (Use arrow keys)
❯ No
  Yes (experimental - Prisma migrations not yet supported)
  
Warning: Introspecting databases with existing data is currently an experimental feature. If you find any issues, please report them here: https://github.co
m/prisma/prisma/issues
 
提示是否在选择的数据库中包含已存在数据。因为是一个新库,所以默认选择No,然后回车确认。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? No
? Enter database host (localhost)
 
输入数据库的主机地址(注意,因为prisma会运行在docker中,所以,这儿需要配置宿主机IP,在类Linux系统上可以通过ifconfig命令来获取IP)。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? No
? Enter database host 10.111.152.242
? Enter database port (5432)
 
回车确认使用默认的Postgres数据库的端口。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? No
? Enter database host 10.xxx.xxx.xxx(此处为你的docker宿主机IP)
? Enter database port 5432
? Enter database user
 
输入数据库的用户名后回车确认。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? No
? Enter database host 10.xxx.xxx.xxx(此处为你的docker宿主机IP)
? Enter database port 5432
? Enter database user postgres
? Enter database password
 
输入数据库用户对应的密码后回车确认。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? No
? Enter database host 10.xxx.xxx.xxx(此处为你的docker宿主机IP)
? Enter database port 5432
? Enter database user postgres
? Enter database password study
? Enter database name
 
输入使用的数据库名称后回车。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? No
? Enter database host 10.xxx.xxx.xxx(此处为你的docker宿主机IP)
? Enter database port 5432
? Enter database user postgres
? Enter database password study
? Enter database name study
? Use SSL? (Y/n)
 
提示是否使用安全的网络协议,这里选择不使用(输入n后回车)。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? No
? Enter database host 10.xxx.xxx.xxx(此处为你的docker宿主机IP)
? Enter database port 5432
? Enter database user postgres
? Enter database password study
? Enter database name study
? Use SSL? No
Connecting to database 18ms
? Select the programming language for the generated Prisma client
  Prisma TypeScript Client
  Prisma Flow Client
❯ Prisma JavaScript Client
  Prisma Go Client
  Don't generate
 
这里选择产生JavaScript客户端脚本(Prisma JavaScript Client)。
 
? Set up a new Prisma server or deploy to an existing server? Use existing database
? What kind of database do you want to deploy to? PostgreSQL
? Does your database contain existing data? No
? Enter database host 10.xxx.xxx.xxx(此处为你的docker宿主机IP)
? Enter database port 5432
? Enter database user postgres
? Enter database password study
? Enter database name study
? Use SSL? No
Connecting to database 18ms
? Select the programming language for the generated Prisma client Prisma JavaScript Client
Created 3 new files:                                                                          
  prisma.yml          Prisma service definition
  datamodel.prisma    GraphQL SDL-based datamodel (foundation for database)
  docker-compose.yml  Docker configuration file
Next steps:
  1. Open folder: cd prisma-study
  2. Start your Prisma server: docker-compose up -d
  3. Deploy your Prisma service: prisma deploy
  4. Read more about Prisma server:
     http://bit.ly/prisma-server-overview
Generating schema... 20ms
Saving Prisma Client (JavaScript) at /Users/chunrong.liu/dev/study/prisma-study/generated/prisma-client/
 
至此,Prisma项目创建并初始化完毕。
 
接下来按昭Next steps下面的步骤提示执行后续操作。
 
通过以下命令切换当前目录至刚创建的项目目录(prisma-study)中。
cd prisma-study/
 
通过docker编排命令在docker中运行prisma服务器。
docker-compose up -d
执行后命令行提示如下:
Creating prisma-study_prisma_1 … done
此时服务运行成功。
 
通过以下命令部署prisma服务。
$ prisma deploy
Creating stage default for service default ✔
Deploying service `default` to stage `default` to server `local` 476ms
Changes:
  User (Type)
  + Created type `User`
  + Created field `id` of type `GraphQLID!`
  + Created field `name` of type `String!`
  + Created field `updatedAt` of type `DateTime!`
  + Created field `createdAt` of type `DateTime!`
Applying changes 1.2s
Your Prisma GraphQL database endpoint is live:
  HTTP:  http://localhost:4466
  WS:    ws://localhost:4466
 
用流程器打开http://localhost:4466/链接地址,可以看到如下的UI界面。
 
运行如下命令可以看到演练数据:
$ prisma playground
Serving playground at http://localhost:3000/playground
 
此时会自动打开浏览器,并显示如下界面:
 
 
关于数据库无法连接的问题:
 
官方参考资料地址:

前端技术之:Prisma Demo服务部署过程记录的更多相关文章

  1. web服务器部署过程记录

    由于之前没有服务器部署经验,又选择了所有软件都是单独编译安装,遇到很多问题,解决之后还是学习到了很多新东西. 如今回过头来还是选择lnmp集成环境的部署方式比较方便快捷:https://lnmp.or ...

  2. 解密国内BAT等大厂前端技术体系-腾讯篇(长文建议收藏)

    1 引言 为了了解当前前端的发展趋势,让我们从国内各大互联网大厂开始,了解他们的最新动态和未来规划.这是解密大厂前端技术体系的第三篇,前两篇已经讲述了阿里和百度在前端技术这几年的技术发展.这一篇从腾讯 ...

  3. 利用webuploader插件上传图片文件,完整前端示例demo,服务端使用SpringMVC接收

    利用WebUploader插件上传图片文件完整前端示例demo,服务端使用SpringMVC接收 Webuploader简介   WebUploader是由Baidu WebFE(FEX)团队开发的一 ...

  4. [转载] 新兵训练营系列课程——平台服务部署及Web框架

    原文: http://weibo.com/p/1001643875679132642345 大纲 微博平台主要负责微博基础功能.接下来将会介绍 平台的作用,以及服务提供的形式 平台Web服务的部署 平 ...

  5. nginx服务部署 说明

    第1章 常用的软件 1.1 常用来提供静态服务的软件   Apache :这是中小型Web服务的主流,Web服务器中的老大哥,   Nginx :大型网站Web服务的主流,曾经Web服务器中的初生牛犊 ...

  6. 绝版珍珍藏:web前端技术学习指南

    绝版珍珍藏:web前端技术学习指南 优秀的Web前端开发工程师要在知识体系上既要有广度和深度!应该具备快速学习能力. 前端开发工程师不仅要掌握基本的Web前端开发技术,网站性能优化.SEO和服务器端的 ...

  7. H5 PWA技术以及小demo

    H5 PWA技术 1.原生app优缺点 a.体验好.下载到手机上入口方便 b.开发成本高(ios和安卓) c.软件上线需要审核 d.版本更新需要将新版本上传到不同的应用商店 e.使用前需下载 2.we ...

  8. ASP.NET Core on K8S深入学习(2)部署过程解析与Dashboard

    上一篇<K8S集群部署>中搭建好了一个最小化的K8S集群,这一篇我们来部署一个ASP.NET Core WebAPI项目来介绍一下整个部署过程的运行机制,然后部署一下Dashboard,完 ...

  9. 2019年一半已过,这些大前端技术你都GET了吗?- 下篇

    在上一篇文章中已经介绍了大前端关于状态管理.UI组件.小程序.跨平台和框架层的内容.在本文中,我会继续介绍编程语言.工程化.监控.测试和服务端,同时也会对下半年大前端可以关注的部分进行展望. 结合个人 ...

随机推荐

  1. python基础(十七)

    今日主要内容 正则表达式 logging模块 一.正则表达式 (一)什么是正则表达式 正则表达式的定义: 是对字符串操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合,组成一个& ...

  2. Java性能调优的9个实用方法

    1.使用StringBuilder StingBuilder 应该是在我们的Java代码中默认使用的,应该避免使用 + 操作符. 一般来说,使用 StringBuilder 的效果要优于使用 + 操作 ...

  3. Spark 学习笔记之 union/intersection/subtract

    union/intersection/subtract: import org.apache.spark.SparkContext import org.apache.spark.rdd.RDD im ...

  4. MongoDB 学习笔记之 入门安装和配置

    下载MongoDB: 下载解压即可使用. 为了启动方便和统一管理, 在Mongo根目录下建立/data, /logs, /conf文件夹. 在conf文件夹下建立mongodb.conf 文件,基本配 ...

  5. 创建新镜像-从已创建的容器中更新镜像并提交镜像(以Nginx为例)

    目标:现在我们主要是修改nginx的index.html,然后做一个新镜像 1.基于nginx:1.12运行一个容器 docker run -d -p 8080:80 --name nginx ngi ...

  6. 2.linux系统基础笔记(延时操作、实时系统中的定时器、事件)

    延时操作 延时操作是操作系统中经常遇到的一种情形.延时的原因很多,有的时候是为了等待外设芯片处理结束,有的时候是为了暂时释放cpu的使用权,有的就是为了希望在一段时间获取资源,如果没法在单位时间内获取 ...

  7. python编程基础之三十

    时间模块: 时间戳:就是当前是键距离1970年1月1日0:0:0的秒数,后面还带小数,可以说是非常精确 时间的表示形式: a.以整数或者浮点数表示一个以秒为单位的时间间隔,这个时间的基础值1970.1 ...

  8. 使用FastReport报表工具生成报表PDF文档

    在我们开发某个系统的时候,客户总会提出一些特定的报表需求,固定的报表格式符合他们的业务处理需要,也贴合他们的工作场景,因此我们尽可能做出符合他们实际需要的报表,这样我们的系统会得到更好的认同感.本篇随 ...

  9. Flutter 修改SDK 路径出现的问题

    更换Flutter SDK 路径之后出现的问题. 解决方法:flutter packages upgrade. 替换: 替换这两个文件里的路径. 同时修改电脑配置文件里的路径: open -a Tex ...

  10. 古剑奇谭三已取消该页导航,B站版本无法登陆

    最近登陆古剑三突然出现这个问题 怎么重开也无法登陆 最后发现是Ie设置问题 解决方法 点中间这个圆形图标打开 小娜 搜索“ie” 点击打开ie之后点右上角的小齿轮 选择“internet选项” 连接- ...