ipunkt / rancherize
rancherize your development workflow
Installs: 6 939
Dependents: 14
Suggesters: 0
Security: 0
Stars: 6
Watchers: 4
Forks: 1
Open Issues: 10
Requires
- ext-json: *
- ipunkt/rancherize-php53: ^1.4.0
- pimple/pimple: ^3.0
- symfony/console: ^3.1
- symfony/event-dispatcher: ^3.1
- symfony/process: ^3.1
- symfony/yaml: ^3.1
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: ^5.6
Suggests
- ipunkt/rancherize-backup-storagebox: Adding backup commands for use with a Hetzner Storagebox service
- ipunkt/rancherize-blueprint-php-cli: PHP command line interface blueprint with cron labels and shell execution
- ipunkt/rancherize-ecr: Publish docker images to an Amazon ECR repository
- ipunkt/rancherize-php72: Enable php version 7.2
- ipunkt/rancherize-publish-traefik-rancher: Set rancher labels for the traefik rancher backend
- dev-master
- 2.51.3
- 2.51.2
- 2.51.1
- 2.51.0
- 2.50.0
- 2.49.0
- 2.48.0
- 2.47.5
- 2.47.4
- 2.47.3
- 2.47.2
- 2.47.1
- 2.47.0
- 2.46.4
- 2.46.3
- 2.46.2
- 2.46.1
- 2.46.0
- 2.45.1
- 2.45.0
- 2.44.0
- 2.43.1
- 2.43.0
- 2.41.1
- 2.41.0
- 2.40.1
- 2.40.0
- 2.39.1
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.2
- 2.36.1
- 2.36.0
- 2.35.2
- 2.35.1
- 2.35.0
- 2.34.3
- 2.34.2
- 2.34.1
- 2.34.0
- 2.33.3
- 2.33.2
- 2.33.1
- 2.33.0
- 2.32.1
- 2.32.0
- 2.31.3
- 2.31.2
- 2.31.1
- 2.31.0
- 2.30.0
- 2.29.6
- 2.29.5
- 2.29.4
- 2.29.3
- 2.29.2
- 2.29.1
- 2.29.0
- 2.28.6
- 2.28.5
- 2.28.4
- 2.28.3
- 2.28.2
- 2.28.1
- 2.28.0
- 2.27.0
- 2.26.0
- 2.25.3
- 2.25.2
- 2.25.1
- 2.25.0
- 2.24.2
- 2.24.1
- 2.24.0
- 2.23.5
- 2.23.4
- 2.23.3
- 2.23.2
- 2.23.1
- 2.23.0
- 2.22.4
- 2.22.3
- 2.22.2
- 2.22.1
- 2.22.0
- 2.21.1
- 2.21.0
- 2.20.9
- 2.20.8
- 2.20.7
- 2.20.6
- 2.20.5
- 2.20.4
- 2.20.3
- 2.20.2
- 2.20.1
- 2.20.0
- 2.19.3
- 2.19.2
- 2.19.1
- 2.19.0
- 2.18.8
- 2.18.7
- 2.18.6
- 2.18.5
- 2.18.4
- 2.18.3
- 2.18.2
- 2.18.1
- 2.18.0
- 2.17.0
- 2.16.2
- 2.16.1
- 2.16.0
- 2.15.1
- 2.15.0
- 2.14.5
- 2.14.4
- 2.14.3
- 2.14.2
- 2.14.1
- 2.14.0
- 2.13.1
- 2.13.0
- 2.12.0
- 2.11.5
- 2.11.4
- 2.11.3
- 2.11.2
- 2.11.1
- 2.11.0
- 2.10.0
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.6
- 2.5.5
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.11
- 2.1.10
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.2
- 2.0.1
- 2.0.0
- 0.1.0
- dev-tcp-proxy-image
- dev-rancher-cli
- dev-in-service-mode-upgrade-fix
- dev-gvvs-update
- dev-justb81-docker-server
- dev-stock-nginx
- dev-gitlab-build
- dev-justb81-docker-compose-1.16.1
This package is auto-updated.
Last update: 2024-12-08 18:47:52 UTC
README
Rancherize is a php cli script based on symfony/console. It makes developing with docker and rancher easy for developers without specialized knowledge in the subjects. This is done by choosing a blueprint that fits your apps required environment and setting abstract requirements instead of of adding and connecting services.
For a concrete example on how the configuration becomes easier through this see the example at the bottom of this page.
IMPORTANT UPDATE
As of 2.23.0 the default behaviour for pushed services has changed to always pull images on an upgrade.
This can be disabled by setting docker.always-pull: false
in either the defaults or the environment.
Usage as docker container (preferred)
Rancherize comes bundled as Docker Container ipunktbs/rancherize
.
Requirements
Rancherize creates configuration to be used with external docker tools. Thus it is necessary to have the following tools installed to use Rancherize:
Install on linux
No need to separately install it. To use it, just make a shell alias:
alias rancherize='docker run -it --init -v $HOME/.rancherize:/home/rancherize/.rancherize -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):$(pwd) -w $(pwd) -e "USER_ID=$(id -u)" -e "GROUP_ID=$(id -g)" ipunktbs/rancherize:2-stable'
or use the provided script script/rancherize.sh
.
From now on use rancherize without other dependencies for your local environment than docker.
Usage in build tools
With build tools like jenkins or gitlab-ci, you cannot rely on the presence of a .rancherize file in the home-dir. For this usecase you can set account settings with environment variables on the docker container on runtime. best practise would be to include these variables via secrets.
DOCKER_SERVER
- registry server (e.g. registry.gitlab.com), ignore or leave empty for dockerhubDOCKER_USER
- username for dockerhub / registryDOCKER_PASSWORD
- password for dockerhub / registryDOCKER_ECR
- true if using AWS ECRRANCHER_URL
- rancher environment api-urlRANCHER_KEY
- rancher api-keyRANCHER_SECRET
- rancher api-secretRANCHER_ACCOUNTNAME_URL
- alternative rancher environment api-url when using rancher.account = 'ACCOUNTNAME'RANCHER_ACCOUNTNAME_KEY
- alternative rancher api-key when using rancher.account = 'ACCOUNTNAME'RANCHER_ACCOUNTNAME_SECRET
- alternative rancher api-secret when using rancher.account = 'ACCOUNTNAME'
Note that RANCHER_ACCOUNTNAME_{URL,KEY,SECRET}
are only parsed when RANCHER_URL
is set. Setting them without default
account will NOT work.
Usage in project
Requirements
Rancherize creates configuration to be used with external docker tools. Thus it is necessary to have the following tools installed to use Rancherize:
docker
https://docs.docker.com/engine/installation/docker-compose
https://docs.docker.com/compose/install/rancher-compose
https://docs.rancher.com/rancher/v1.2/en/cattle/rancher-compose/#installation
Installation
Rancherize is installed using composer
composer require 'ipunkt/rancherize:^2.5.0'
Configuration
Accounts
Rancherize knows 2 types of accounts:
- docker accounts. They are used to push images to docker hub
- rancher accounts. They are used to deploy your app to your rancher environment
Both are managed in the json file ~/.rancherize
which should be set to be only readable by your own user.
For easy editing use the following command. It opens the file in your $EDITOR
and creates a default file
if it does not exist yet.
vendor/bin/rancherize rancher:access
Environments
Rancherize configuration is split into environments
. A typical app knows at least a local
and a production
environment. Environments are configured by editing the file rancherize.json
inside the app work directory.
Note that all configuration values can also be set in the defaults
section. Values in this section will be used if the
configuration value does not appear in the environment
See Environments and Defaults for a longer explanation on how to best use environments
The command init
can be used to create an initial configuration for an environment.
It will prompt the blueprint to create a sensible default production configuration. If the --dev
Flag is used then
a configuration for a local development environment is created instead.
vendor/bin/rancherize init [--dev] BLUEPRINT ENVIRONENTNAME1 ENVIRONEMNTNAME2... ENVIRONMENTNAMEX
e.g.
vendor/bin/rancherize init --dev webserver local
vendor/bin/rancherize init webserver production staging
Set Environment Variable
The command environment:set
exists to conveniently set an environment value for all environments
. It will go through
all environments
, display the current value and ask for the new value. If none is given then the old value
will be used again.
vendor/bin/rancherize environment:set VARIABLENAME
e.g.
vendor/bin/rancherize environment:set APP_KEY
Development Environment
The command start
exists to start an environment of your app on the local machine.
vendor/bin/rancherize start ENVIRONMENTNAME
e.g.
vendor/bin/rancherize start local
Note that this command does not currently build a docker image from your work directory so the environment
should be
set to mount your work directory directly. For the WebserverBlueprint this means setting
"use-app-container": false
"mount-workdir":"true"
Theses settings are included when initializing with the --dev
flag
Deploy
Push
The command push
exists to deploy the current state of your work directory into Rancher.
vendor/bin/rancherize push ENVIRONEMNT VERSION
e.g.
vendor/bin/rancherize push staging v1
- The current state of your work directory is build as docker image and tagged as
$(docker.repository):$(docker.version-prefix)VERSION
- The built Image is pushed to docker hub using the credentials from the global configuration named
$(docker.account)
- The current configuration of the stack in rancher is retrieved
- If the stack does not exist yet it is created empty
- The apps configuration is added to the stack configuration
- The app is deployed into the stack
- If no other version of the service is found it will be created
- !NEW! If
rancher.in-service
is set totrue
then a rolling upgrade will be triggered to a non-versionized name and subsequently in-service upgrades of this service - If the same version of the service is found then an in-service upgrade is triggered
- If a different version of the service is found then a rolling-upgrade ist triggered
- In case of an in-service upgrade rancherize waits for the stack to reach
upgraded
and confirms the upgrade.
You can setrancher.upgrade-healthcheck
totrue
to wait for it to reporthealthy
instead. Not that this only works if a service has a health-check is defined(not yet supported through rancherize)
Build image
The command build-image
exists to build the current state of your work directory into the docker registry, then deploy
them via push -i
.
It is essentially the push
command without any interaction with rancher.
Blueprints
Blueprint neutral configuration
Known Blueprints
Developing Blueprints
See the Blueprint readme for more information on how to develop your own blueprints