文章目录
线下docker调试好的hasura+postgresql部署到宝塔面板过程
一.线下
1.安装Windows版docker桌面客户端
2.在本地目录新建docker-compose.yml文件
文件内容
version: '3.6'
services:
postgres:
image: postgres:12
ports:
- "5432:5432"
restart: always
environment:
POSTGRES_PASSWORD: postgrespassword
graphql-engine:
image: hasura/graphql-engine:v2.0.10
ports:
- "8080:8080"
depends_on:
- "postgres"
restart: always
environment:
## postgres database to store Hasura metadata
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
PG_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to run console offline (i.e load console assets from server instead of CDN)
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
## uncomment next line to set an admin secret
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
volumes:
db_data:
3.进入docker-compose.yml所在目录
cmd命令行运行docker-compose up -d
(构建compose并在后台运行)
4.进入hasura,连接数据库
5.创建数据表,配置好表关系
测试没有问题,就可以部署到线上
二.线上
1.用宝塔面板自带的docker,将docker-compose.yml文件内容拷贝到compose模板
2.添加compose项目,系统会自动拉取镜像并运行容器
3.将本地数据卷数据上传到宝塔宿主机数据卷覆盖
# 本地数据卷位置
在电脑资源管理器访问以下指令可以进入.vhdx中
\\wsl$\docker-desktop
\\wsl$\docker-desktop-data