Getting Started
This guide will walk you through a simple standalone Pico deployment that does not use a secret store for credentials. This is not recommended for production use if you want to securely pass credentials to services such as databases or API servers.
Deploy Pico
The first step is to get a running Pico instance using the example configuration stored in this repository.
Fork The Examples
Now, to properly demonstrate how Pico works with GitOps/IaC, go ahead and fork the config repository and the target repository and clone these to your computer.
Replace picostack With Your Username
Open up the file main.js inside the config repo and replace the url
property with your fork:
Commit the change and push, now you're ready to deploy!
Now from here on, anywhere in the documentation and configuration files that
references the URL
https://github.com/_YOUR_USERNAME_/pico-example-config-no-auth, replace
_YOUR_USERNAME_ with your own GitHub username.
Deploy
- In Container
- On Host OS
As Container
Make a new folder for this guide then grab this docker-compose.yml file:
And run:
Now you have a running instance of Pico, you should see the following in your terminal:
note
If you deployed Pico with Docker Compose, your output will look slightly
different to the example below since it will be prefixed with pico_1 |.
Congratulations! You just:
- Started Pico
- Told Pico to read configuration files from a repository
- Watched Pico pull a target and execute
docker-compose upinside it
Update the Target
Leave Pico running in the background - it's designed to be left to its own devices while you push commits.
What you did above was pull your fork of the Pico config example. This example
contained a single target, that lives at
https://github.com/_YOUR_USERNAME_/pico-example-target so now it's time to
push a change to this repository and watch Pico react to it.
This repository already has a branch named merge-me that contains a small
change to demonstrate this.
Open up the pico-example-target directory in your favourite terminal or editor
and merge the branch named merge-me into master:
If you open up docker-compose.yml you'll notice the hello service has
changed:
This merge swapped out the image from hello-world to busybox and added a
command that prints to the console.
Commit this change to master and push. Switch back to the terminal where you started Pico and you'll see some new output shortly:
Pico pulled the new commit and ran docker-compose up. Docker Compose then did
the rest by diffing against the new Compose configuration, stopping the old
hello-world container and starting a new busybox container with the greeting
message.
And of course you can git revert HEAD and roll back to the old configuration.
Update the Config
Now you can update the configuration in your fork of the config repo.
Open up the main.js file and duplicate the target a couple of times, be sure
to give them unique names:
Push this and you'll see Pico spawn two more targets.
Play around adding and removing targets, you can use any project you want, it doesn't need to use Docker Compose.
Conclusion
This example demonstrated a simple automation setup for applications deployed with Docker Compose. Replace the hello-world example with a full application and Pico allows you to automatically update configuration variables, image versions, volume mounts etc. simply by pushing them to Git.
On top of this, you can then apply Git branching strategies and a review process to your configuration files. This is usually referred to as GitOps or Infrastructure-as-Code.