这个部署最终失败了,失败的报错是:raise exceptions.JSONWebTokenError(_('User is disabled'))
但是下方的部署都是从官方的手册或者github中收集过来的,所以还是值得记录一下的.
repository | Usage | link | framwork |
---|---|---|---|
saleor | GraphQL(Programmar) | http://106.14.24.151:8000/graphql/ | Django |
saleor-dashboard | Administrator(sellor) | http://106.14.24.151:9000/ | Nodejs |
saleor-storefront | Customer | http://106.14.24.151:3000/ | Nodejs |
Official version needed:
Name | version | Official Reference |
---|---|---|
Python | 3.5 or later | Installation for Linux |
Node | Version 10 or later | Installation for Linux |
Saleor | v2.9.0 | Documentation – Saleor Commerce Versions |
Saleor-storefront | newest version | saleor-storefront and [5] |
Saleor-dashboard | v2.0.0 | saleor-dashboard |
# git clone https://gitee.com/BoardGame/saleor
cd saleor
git checkout v2.9.0
# git clone https://gitee.com/BoardGame/saleor-dashboard
# cd saleor-dashboard
# git checkout v2.0.0(切换到官方推荐版本)
# git clone https://gitee.com/BoardGame/saleor-storefront
# cd saleor-storefront
#git checkout v0.7.0
根据[5],应当使用saleor-storefront的最新版,不要使用稳定版,所以上面的这个稳定版本是不行的。
#---------------------------------------------------------------------------------------------------------------
~/.bashrc加入下面设置
export APP_MOUNT_URI="/dashboard/"
export API_URI='http://106.14.24.151:8000/graphql/'
export STATIC_URL='http://106.14.24.151:9000/'(这个留着待观察)
注意,部署顺序是saleor,saleor-dashboard/saleor-storefront
后两者的运行严重依赖前者,部署顺序不要搞错。
#--------------------------------------saleor部署(start)-----------------------------------------------------
编辑saleor/site/migrations/0002_add_default_data.py
修改 "localhost:8000"
为:
"106.14.24.151:8000"
这个东西的目的是:
用户注册邮件的时候,网站发送给客户的注册确认邮件里面的图片显示的。
如果不改,会导致图片无法显示。
当然,这个文件是要写入数据库的,这个文件一旦修改,那么后面的python manage.py migrate这个命令必须执行。
修改settings.py
SECRET_KEY="appleyuchi"(这个字符串随便写就好)
ALLOWED_HOSTS=["106.14.24.151","localhost","127.0.0.1"]
ALLOWED_CLIENT_HOSTS=["106.14.24.151","localhost","127.0.0.1"]
EMAIL_FILE_PATH = ''
# https://github.com/mirumee/saleor/issues/3703
# 根据这个链接,不设置也行
EMAIL_HOST_USER = '753743312@qq.com'
EMAIL_HOST_PASSWORD = 'wyitwdvtfaahbbfa'
EMAIL_HOST = 'smtp.qq.com'
EMAIL_PORT = 587
EMAIL_BACKEND ='django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
DATABASES = {
"default": dj_database_url.config(
default="postgres://postgres:postgres@localhost:5432/saleor", conn_max_age=600
)
}
终端:
cnpm install
cnpm run build-emails
python manage.py makemigrations
python manage.py migrate
python manage.py populatedb --createsuper(同步样例数据到postgreSQL数据库,创建管理员账户)
python manage.py runserver 0.0.0.0:8000 &
jobs
disown -h %1
关闭远程连接
浏览器打开
http://106.24.14.151:8000/graphql
#--------------------------------------saleor部署(end)-----------------------------------------------------
#--------------------------------------saleor-dashboard部署(start)-----------------------------------------------------
vi webpack.config.js第62行
改成:
devServer: {
compress: true,
contentBase: path.join(__dirname, dashboardBuildPath),
historyApiFallback: true,
hot: true,
host: '0.0.0.0',
port: 9000
},
cnpm install
cnpm start &
jobs
disown -h %1
关闭远程连接
浏览器打开:
#---------------------------------------saleor-dashboard部署(end)------------------------------------------------------
#---------------------------------------下面是saleor-storefront部署(start)--------------------------------------------------------
cd saleor-storefront
vi cypress.json
{
"baseUrl": "http://106.14.24.151:3000",
"env": {
"API_URI": "http://106.14.24.151:8000/graphql/"
},
"defaultCommandTimeout": 15000,
"requestTimeout": 15000,
"viewportWidth": 1400,
"viewportHeight": 660,
"projectId": "ftxg4w"
}
package.json里面一句改成:
"start": "cross-env NODE_ENV=develop webpack-dev-server --history-api-fallback --watch
--host 0.0.0.0 --disable-host-check --port 3000 --mode development --hotOnly",
cnpm install
cnpm start &
jobs
disown -h %1
关闭远程连接
浏览器打开
#--------------------------------------saleor-storefront部署(end)-------------------------------------------------------------
saleor这个东西就是个展示,凡是特别特别重要的,涉及重大市场的功能,肯定不给你做,
都给你做完了,人家吃什么?
所以说,除非你有意向去请对方定制功能,否则别想着自己单枪匹马搞,有你累的。
开源项目就是这么谋生的,大家都要吃饭,理解一下吧。
Reference:
[1]Running Saleor with Docker Compose
[2]add Dockerfile and nginx conf
[3]Saleor ran into an unexpected problem. When login /dashboard?
[4]https://gitter.im/mirumee/saleor?at=5e5d84e290a8295824fefcb3
[5]GRAPHQL errors after last update