Jayden

Jayden

Redeploy MixSpace+Shiroi

Intro#

Yesterday, I just updated the blog's architecture, and this morning I woke up to find that the server had expired, causing the website to go down directly, without even a reminder email about the expiration.

The plan was not to renew after expiration, and after it expired, I was unable to connect to the server, and the data inside could not be retrieved. Fortunately, I had a good backup habit and regularly backed up the data to OneDrive. For details, see this article.

But awkwardly, I had only backed up the data and not the deployed environment variables, which led to some issues that I think are worth documenting.

Backend Deployment#

Consistent with the previous deployment article, the only thing to note, and the trouble encountered in this deployment, is the writing of the .env file. In ALLOWED_ORIGINS, only fill in the domain name, do not fill in https://xxu.do.

Frontend Deployment#

The deployment method this time: Using GitHub Action to build Shiroi and then deploy to a remote server, mainly referenced this article.

First, perform the following operations on the server:

  1. Install Nodejs and unzip
  1. Install Node.js, npm, pnpm, pm2, sharp
  1. In your server's home directory, create a directory for shiro, then create a .env file to fill in your variables.
  1. Then fill in the corresponding environment variables. For a single domain, NEXT_PUBLIC_API_URL and NEXT_PUBLIC_GATEWAY_URL should be filled in as follows. GH_TOKEN can be created from here, and just check the repo permission.
  1. After forking the project, add the following content in Settings -> Secrets and variables -> Actions -> Repository secrets:
  • HOST server address
  • USER server username
  • PASSWORD server password
  • PORT server SSH port
  • KEY server SSH Key (optional, either password or key)
  • GH_PAT GitHub Token that can access the Shiroi repository

The GH_PAT can be kept the same as the GH_TOKEN above.

  1. In the Actions of the forked repository, enable the workflow; after modifying the build_hash file arbitrarily, the workflow will start. If it runs successfully, you can check if there are built files in your server's /root/shiro folder; it initially failed to run, and the reason was found to be that pm2 was not deployed, for reference.

  2. Action scheduled execution: Go to the GitHub forked project, modify the .github/workflows/deploy.yml file, and uncomment the schedule: and - cron: '0 3 * * *' lines.

Nginx Reverse Proxy#

Example for a single domain:

Outro#

This time, adopting a new frontend deployment method has indeed solved the problem of excessive memory usage.

Additionally, it brings a lesson: always back up the .env file, as it will avoid many troubles during redeployment.

This article is synchronized and updated to xLog by Mix Space. The original link is https://xxu.do/posts/geek/redeploy-MixSpace%2BShiroi

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.