-
Notifications
You must be signed in to change notification settings - Fork 0
Strapi application setup
For a Strapi application, we use pm2 for deployment. This will create a node instance on the server. The create_strapi_site command will add the required configuration to nginx. In the current set-up there is no support yet for multiple Strapi running on the same server. But this can easily be achieved by modifying the create_strapi_site so it will prompt for the right port number. This port number should then be equal to the PORT number in the .env file.
-
Login to the remote server
ssh <user>@<host>. Make sure that you are using the sameuseras you define in your local.envfile. -
Create an ssh key
cd ~/.ssh
ssh-keygen -f github_<github_username>_<repo> -t ecdsa -b 521
Replace <github_username> with the username that the repo belongs to, and replace <repo> with the name of the repo.
3) Update (or create) ~/.ssh/config file
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github_<github_username>_<repo>
If this code already exists, you can copy the IdentityFile line, and use your newly created keyfile
- Add ssh key to the list of deploy keys of your repo
Go to your repo, and go to
settings > deploy keys > add deploy key. For the title use @, and paste the contents of~/.ssh/github_<github_username>_<repo>.pubhere. Leaveallow write accessunchecked!
- Download the
ecosystem.config.jsfile and place it in the root of your project. - Run
pm2 deploy production setup
DEPLOYMENT_USER=<user>
DEPLOYMENT_HOST=<host>
DEPLOYMENT_PATH=/var/www/vite/<project>
MAX_BACKUPS=5
- Replace the
userwith the username required to login to the remote server. - Replace
hostwith the name of the server (no www, https or other prefixes, ip address could be fine as well) - Replace
projectwith the name of the directory that you want to install the project
- Add
{"deploy": "bash deploy.sh"}to your package.json file
Since all off the credentials are located in the .env.production file, it is safe to commit the deploy.sh file to your repo. The .env.production should be added to your .gitignore preferably.
- Run
yarn deployto deploy upload the project to the remote server.