Scenario: getting colleagues up-to-speed

If someone joins your project, then it makes sense to share your working environment with them. At the same time, you want working environments to be independent, so that each project member can arrange it to their preferences. This is achieved by having a shared configuration from which you cherry-pick the parts you need.

We will continue where we left off in part 3 (Scenario: using project-specific sets of aliases). If you haven’t done the steps of the previous scenario, run this to get started:

cd /tmp
git clone git@github.com:mnieber/dodo-commands-tutorial.git

# Copy the end state of part 3 of the tutorial
cp -rf ./dodo-commands-tutorial/part3/after ./tutorial

# Create and activate a dodo environment for our project
cd ./tutorial
$(dodo env --init tutorial)

Preparing the configuration files for sharing

Let’s start by activating the tutorial environment:

$(dodo env tutorial)

If you followed the tutorial so far (or if you’ve cloned the latest starting point) then we have a working Dodo Commands configuration in /tmp/tutorial/.dodo_commands, and some scripts in /tmp/tutorial/commands. Let’s see how we can share this configuration with colleagues.

The first step we will take is to move some files into a src directory that we can add to git:

cd /tmp/tutorial
mkdir src
mv commands/ docker-compose.yml Dockerfile reader/ writer/ time.log src/

cd src
git init
git add *
git commit -m "First commit"

    [master (root-commit) 56f79a1] First commit
    9 files changed, 77741 insertions(+)
    create mode 100644 Dockerfile
    create mode 100644 commands/greet.py
    create mode 100644 commands/mk.meta
    create mode 100644 commands/mk.py
    create mode 100644 docker-compose.yml
    create mode 100644 reader/Makefile
    create mode 100644 time.log
    create mode 100644 writer/Makefile
    create mode 100644 writer/write_periodically.py

We’re not adding the .dodo_commands directory to git, because then the ownership of these files will become a problem. It’s better if each developer can tweak the configuration to their liking.

Note

The purpose of ${/ROOT/version} is to track the version of the configuration file. If the version in the local file is smaller than the version in the shared file, then it means that your colleague added something to the shared file. In this case, use dodo diff to synchronize your local file with the shared one. When you are done, make sure to edit the ${/ROOT/version} value so that it’s the same as the value in the shared file (this marks the fact that you are up-to-date with the shared configuration).

Bootstrapping a Dodo Commands environment

We are now ready to let a colleague work on our project. To similate the steps that our colleague will take on their computer, we will create an environment named colleague and pretend that this is the “tutorial” environment that they will use. We will use the bootstrap command to initialize it. This will provide our colleage with a copy of the configuration files that we just added to git.

$(dodo env --create colleague)
dodo bootstrap --git-url=/tmp/tutorial/src src extra/dodo_commands/config --confirm

    (/tmp) mkdir -p /home/maarten/projects/colleague

    confirm? [Y/n]

    (/tmp) cp -rf \
      ~/projects/colleague/src/extra/dodo_commands/config/config.yaml
      ~/projects/colleague/.dodo_commands/config.yaml

    Copying shared environment files to your local environment...

    Warning, destination path already exists: ~/projects/colleague/.dodo_commands/config.yaml. Overwrite it?
    confirm? [Y/n]

    (/tmp) cp -rf
      ~/projects/colleague/src/extra/dodo_commands/config/server.writer.yaml
      ~/projects/colleague/.dodo_commands/server.writer.yaml
    confirm? [Y/n]

    (/tmp) cp -rf
      ~/projects/colleague/src/extra/dodo_commands/config/server.reader.yaml
      ~/projects/colleague/.dodo_commands/server.reader.yaml
    confirm? [Y/n]

    (/tmp) cp -rf
      ~/projects/colleague/src/extra/dodo_commands/config/docker.yaml
      ~/projects/colleague/.dodo_commands/docker.yaml
    confirm? [Y/n]

Because we used the --confirm flag, the command asks permission to copy the shared configuration files to our local configuration directory. Let’s look at the arguments that were supplied in the call to bootstrap:

  • We used a --git-url that points to our local git repository. Usually you would use a remote git url.

  • The repository is cloned to the src subdirectory of colleague’s project directory.

  • The shared configuration files are copied from the extra/dodo_commands/config location (which is relative to src) to the configuration directory of colleague.

Detail sections

Open the adjacent tabs for more detail sections