- Bash
- Docker
- Git
To start working with bootstrap simply clone bootstrap repository with our repository upstream renamed to upstream. It will help you get the updates from our repository while keeping your changes for your project.
git clone git@github.com:SwingDev/bootstrap-bootstrap.git . -o upstreamScript updates itself automatically on a daily basis.
The repository consists of three main components:
modules.txt- which points to all dependent repositoriesdocker-compose.yml- which describes how the components should build and interactboostrap.sh- main script for managing and running the project
To fetch all dependencies simply run:
./bootstrap.shTo run the project simply use up command:
./bootstrap.sh upOptionally you can pass a list of services to be rebuilt:
./bootstrap.sh up api webSome services will need to perform a certain set of actions before they are able to start successfully. This might include eg. running migrations, setting up fixtures, etc.
To accommodate this, this script will run all the setup scripts, every time they change since the last setup run (as per last git modification timestamp).
Adding the setup scripts is as simple as
mkdir -p ./setup
touch ./setup/initialize-database.shAll the .sh files in ./setup directory are considered to be setup scripts. They are executed in alphabetical order as per bash.
ATTENTION: setup scripts must be idempotent (able to run multiple times without adverse effects), as they will run multiple times - on each change to the setup scripts.
Setup step will run right after up command.
Setup can be forced (regardless of the timestamps) by running:
./bootstrap.sh setupNOTE: each setup script will be run up to 10 times, with a delay of 3 seconds (determined by it's exit code).
You can just build the services without starting them up:
./bootstrap buildAs with other commands you can specify which services to build
./bootstrap build apiTo see the logs use the logs command:
./bootstrap.sh logsTo see logs from only a couple of services, pass their names as arguments:
./bootstrap.sh logs api webYou can run arbitrary commands within running containers via:
./bootstrap.sh exec api /bin/shThe above example will start a shell on the api service.
To stop the project simply use down command:
./bootstrap.sh downStopping will delete all containers and all network leftovers, so make sure to mount everything you need persisted.
To check on which branch each of the modules is, simply use the following command:
./bootstrap.sh branch# Example of the output
frontend: master
backend: feature/#54
pdf-generator: masterTo check status of all the modules, use the following command:
./boostrap.sh status# Example of the output
frontend:
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
backend:
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
new-file.txt
nothing added to commit but untracked files present (use "git add" to track)
pdf-generator:
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree cleanIt is possible to specify custom docker-compose.yml location. It might be useful if you have few configurations with different settings - for example configuration with frontend live-reload, backend live-reload or verbose output or different configuration for your CI with different ports binding. To do that, use -c parameter for any command:
./bootstrap.sh -c docker-compose.frontend.yml up
To add new dependency, simply use:
./bootstrap.sh add-module <repository-url> <directory>This will add new line to modules.txt and fetch the repository.
If fetched repository constains .docker-compose.template.yml, it will be appended to your docker-compose.yml file.
In future versions we plan to extend this with templating mechanism, for now it is just pasting the content with the proper indentation (name of the container is set to the name of the directory you provide for the command).
In the template, you can use <PROJECT_DIR> template string which will be replaced with a directory name where the project will be fetched. You can use it to setup docker volumes correctly for example.
The tool is an Open Sourced version of the tool we are using internally in SwingDev.
We are open to your pull requests! If you want to improve the project, simply create a new pull request describing in detail new functionality, including update to this readme.
This software is provided under MIT license.