Deployment
To make deployment a easy process, I created a Makefile with different commands allowing user to deploy application with almost Zero Downtime
There are various commands involved while deployment to production. These commands are useful for development purpose as well.
Before deploying make sure you change the repository name (if you have changed it) for Flags on line:25
This script uses .env file so make sure .env is in-place when running the commands.
Here for deployment above command will create a build directory inside the project with three sub-directories
current - This is the symlink of latest release
releases - Contains the directories with different release versions
shared - Any files or folders required to be shared between the releases
Each release will be versioned under the format: <project-name>-v<Tag>-<YMDHIS>-<commit-hash>
For e.g. fiber-boilerplate-v0.0.1-20210131120000-1b1843
Command
Description
make create-folder
This command will create above mentioned three folders
for the release if not already exists
make git-checkout
This command will checkout the master branch and
pull latest changes
make git-push
This command will push all changes done on
production to repository
make dev-push
This command accept an argument COMMIT_MESSAGE
and
push the changes to repository from developers platform
For e.g.
make dev-push COMMIT_MESSAGE="Test"
make build-app
This command will create build the project to binary
to latest release folder
make copy-config
This command will copy .env, config.yml and assets
from project to latest release folder
make install-fe-dependencies
This command will install front end dependencies using yarn
Make sure you've installed nodejs and yarn
make compile-fe
This command will compile the front end UI to respective
public folder
make copy-assets
This command will copy the JS, CSS, Images, Fonts, and
html files from project to current release
make create-symlink
This command will create symlink for latest release and
shared directories to current release
make migrate
This command will migrate all database changes
make build
This command is composed of:
create-folder, git-checkout, build-app, copy-config,
copy-assets, create-symlink and migrate
make kill
This command will try to kill the PID using the port
make start
This command will start the current release
make restart
This command is composed of kill
and start
make deploy
This command is composed of build
and restart
make rollback
This command will rollback the release to previous release
make rollback-to
This command will rollback to specific release provided
as argument.
For e.g.
make rollback-to RELEASE_TAG=project-name-20210115171923-7dc9021
Building Project
You can build the project using command make build
You can deploy the project to production using make deploy
Easy Rollback
With the command make rollback
and make rollback-to
you can easily rollback to previous release version or specific release version
Last updated