Creating first service¶
Service definitions are docker-compose.yml files, with addition of Harbor’s patterns which allows to automate and standardize the way of environment preparation.
Few rules:
- YAML files are stored at
./apps/conf
- The naming:
apps.MY-APP-NAME.yaml
for applications, andinfrastructure.MY-TECHNICAL-APP-NAME.yaml
for technical services (health checks, backups etc.) - Volumes with configuration files eg. nginx.conf - should be in
./container/MY-APP-NAME
directory - Volumes with external git repositories should be in
./apps/www-data/MY-APP-NAME
directory - Volumes with dynamic data such as user uploads should be in
./data/MY-APP-NAME
directory
Generating a service from template using Cooperative¶
Best way to create a service is to use a generator - to avoid common mistakes.
Demo: https://asciinema.org/a/348867
harbor :cooperative:sync
harbor :cooperative:install harbor/webservice
The below example will sync coop repositories, then use harbor/webservice
template to generate docker-compose yaml file,
that will be placed in ./apps/conf
directory.
Creating a service - the manual way¶
Create a standard docker-compose format file in ./apps/conf
directory, name it properly eg. apps.adminer.yml
and put following example contents:
version: 2.3
services:
adminer:
image: adminer
restart: always
environment:
VIRTUAL_HOST: db.example.localhost
VIRTUAL_PORT: "80"
LETSENCRYPT_HOST: db.example.localhost
LETSENCRYPT_EMAIL: example@example.org
labels:
org.riotkit.updateStrategy: "rolling"
Bringing up created service¶
Use :service:up
task to bring up a recently created service.
harbor :service:list
harbor :service:up service-name
After checking that everything works correctly the service definition + configuration files placed in ./container
directory should be pushed to GIT.