Intro
Previously, I explained how to deploy Mix Space. Now there's a much easier way, so I'd like to share it.
This post only covers deployment; for more detailed instructions, see the previous article.
Installing Docker
If your server is in China, I recommend using Alibaba Cloud's mirror accelerator. The installation command is:
BASH
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
If your server is outside China, you can install directly with the official script:
BASH
curl -fsSL https://get.docker.com | bash -s docker
If you've successfully installed Docker and Docker Compose, you can check the versions with:
BASH
docker -v
docker compose version
Deploying Mix Space Core
- Fetch the configuration file
BASH
cd && mkdir -p $HOME/mix-space/core && cd $_ # 拉取 docker-compose.yml 文件
wget https://fastly.jsdelivr.net/gh/mx-space/core@master/docker-compose.yml
- Create the environment variables file
BASH
vi .env
- After filling in the following, press
ESC, type:wq, and save and exit
ENV
JWT_SECRET= #JWT 密钥:需要填写长度不小于 16 个字符,不大于 32 个字符的字符串,用于加密用户的 JWT,务必保存好自己的密钥,不要泄露给他人。
ALLOWED_ORIGINS= #被允许的域名:需要填写被允许的域名,通常是前端的域名,如果允许多个域名访问,用英文逗号,分隔。
ENCRYPT_ENABLE= #如果你确定要开启加密,将 false 改为 true,开启加密后,你需要在下方填写加密密钥。
ENCRYPT_KEY= #如果你不知道这是什么,那么不建议开启此功能,具体内容可参考 https://mx-space.js.org/usage/security.html
Start the backend
BASHdocker compose up -d
Frontend Deployment
- Fetch the configuration file
BASH
cd && mkdir -p $HOME/mix-space/core && cd $_ # 拉取 docker-compose.yml 文件
wget https://raw.githubusercontent.com/Innei/Shiro/main/docker-compose.yml
- Fetch the environment variable file, then edit its contents
BASH
wget https://raw.githubusercontent.com/Innei/Shiro/main/.env.template .env
Start the backend
BASHdocker compose up -d
Nginx Reverse Proxy
Point your domain to the server.
Request a certificate
BASHcurl https://get.acme.sh | sh; apt install socat -y || yum install socat -y; ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt ~/.acme.sh/acme.sh --issue -d xxu.do --standalone -k ec-256 --force --insecure mkdir -p /etc/pki/xxu.do ~/.acme.sh/acme.sh --installcert -d xxu.do --key-file /etc/pki/xxu.do/server.key --fullchain-file /etc/pki/xxu.do/server.crt service postfix reload;service dovecot reload;service nginx reload #重载服务Set up the reverse proxy:
BASHvi /etc/nginx/nginx.confModify the domain and certificate paths in the example below, then add it to the configuration file:
Updating
Go to the core or frontend folder, then run:
BASH
docker compose pull && docker compose up -d