這個部署最終失敗了,失敗的報錯是:raise exceptions.JSONWebTokenError(_('User is disabled'))
但是下方的部署都是從官方的手冊或者github中收集過來的,所以還是值得記錄一下的.
部署分爲saleor,saleor-dashboard,saleor-storefront三個部分
官方版本要求:
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 = '[email protected]'
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