Fub is a remote execution and deployment tool.
It is essentially a wrapper for Fabric that overrides some settings.
Hosts are the machines (local or remote) where the commands will be run.
Fub by default connects to the tedxntua
host, if one exists in the user's SSH config
file.
You can edit them in fub/hosts.py
or override them through the -H
argument
of the fub
command (e.g. fub -H 8.8.8.8 deploy
).
Stages are the available instances of the application. We currently have two
stages, staging
and production
. See here
for an explanation. Stages are defined and configured in fub/tasks/stages.py
.
Active stage is the stage for which a fub command is run. For example,
running git.pull
when production
is the active stage, will run a git pull
command in the code directory of the production instance.
Tip: Run
fub --list
to view all the available commands.
We list the most important commands below:
It sets the active stage to staging
. Shortcut: fub stag
.
Chain this command with others so that they run with staging
as the active
stage.
fub staging git.pull
It sets the active stage to production
. Shortcut: fub prod
.
Chain this command with others so that they run with production
as the active
stage.
fub prod deploy
Runs the deploy pipeline for the instance of the active stage, which by default
is the staging
for the deploy
command.
It executes the following functionality:
- Fetches the
master
branch of the main repository and applies the changes. - Installs any new Python dependencies.
- Installs any new npm dependencies.
- Creates production build for frontend.
- Runs
collectstatic
command of Django. - Compiles any new translations.
- Applies any new migrations.
- Restarts application server.
Tip: Run
fub --help TASK
to read the documentation and the arguments of a given task.
- The tasks are run by calling
fub task1 task2
instead offab task1 task2
. - The task scripts are stored in
fub/tasks
instead of afabfile.py
script. - Overridden arguments:
prompt_for_passphrase
is set toTrue
by default.
Fabric by default adds a console script
to your project with the name fab
.
Fub does the same in the setup.py
by pointing to the fub/main.py
module,
where Fub is created as a Fab
subclass, which in turn is an invoke.Program
subclass.