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:
- Install
Nodejsandunzip
- Install
Node.js,npm,pnpm,pm2,sharp
- In your server's home directory, create a directory for
shiro, then create a.envfile to fill in your variables.
- Then fill in the corresponding environment variables. For a single domain,
NEXT_PUBLIC_API_URLandNEXT_PUBLIC_GATEWAY_URLshould be filled in as follows.GH_TOKENcan be created from here, and just check the repo permission.
- After forking the project, add the following content in
Settings -> Secrets and variables -> Actions -> Repository secrets:
HOSTserver addressUSERserver usernamePASSWORDserver passwordPORTserver SSH portKEYserver SSH Key (optional, either password or key)GH_PATGitHub Token that can access the Shiroi repository
The GH_PAT can be kept the same as the GH_TOKEN above.
-
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/shirofolder; it initially failed to run, and the reason was found to be that pm2 was not deployed, for reference. -
Action scheduled execution: Go to the GitHub forked project, modify the
.github/workflows/deploy.ymlfile, and uncomment theschedule: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