This folder provides makefile based API to help with devops tasks automation. Tasks are defined as make targets and could be run either on host or in docker containers. The folder includes the following files / dirs:
- Makefile defines pattern rule
%_in_docker
to run any target inside docker container and provides a set of other generally useful targets - docker folder holds docker related routine
- make
- docker
- docker-compose
This module provides a set of dockerfiles based on ubuntu xenial
and centos7
.
They have an hierarchy: rust
images based on base
ones.
Each version of these images is represented as separate dockerfile named Dockerfile.<VERSION>
.
base
docker images include generally useful packages and fpm
along with rvm
and ruby
.
Notes:
- consider to use shell in login mode if you need
fpm
(rvm
andruby
) available in the$PATH
- consider to add all non-root users that will be using rvm to
rvm
group
Environment variables:
BASE_ENV_VERSION
version of the dockerfileFPM_VERSION
version for thefpm
- (
centos7
only)RUBY_VERSION
version of theruby
rust
docker images are based on the base
images and adds rust
.
Supported arguments:
RUST_VERSION
: version of therust
to install. Default: depends on dockerfile version
Environment variables:
- RUST_ENV_VERSION
version of the dockerfile
- RUST_VERSION
version of the rust
%_in_docker
re-runs make for the matched target%
inside$(DOCKER_NAME):$(DOCKER_TAG)
docker image. Requires targetimage_%
to be defined and expects that it builds necessary docker image. Environment variablesDOCKER_NAME
andDOCKER_TAG
should be defined as wellpackage
creates a package from the source code using fpm tool. Could be configured byFPM_*
environment variablesimage_base
builds docker image with generally useful packages andfpm
installedimage_rust
builds docker image withrust
installed
Expects the following targets to be defined in child makefiles:
image_%
: should build image with necessary environment to execute target%
OSNAME
: switches OS context, possible values:xenial
,centos7
. Default:xenial
EXPORT_ENV
: list of variables that should be exported. Could be expanded by child dockerfiles. The list is also passed to in-docker make targets environment. Default:OSNAME PROJECT_NAME
PROJECT_DIR
: absolute path of the top level project dir. Default: resolved asgit rev-parse --show-toplevel
PRE_PACKAGE_GOALS
: space separated list of targets that should be updated beforepackage
target execution, i.e.$(PRE_PACKAGE_GOALS)
is a prerequisite for the target. Default: not setDOCKER_NAME
: name of the image to use in%_in_docker
target's recipe. Default: not setDOCKER_TAG
: tag of the image to use in%_in_docker
target's recipe. Default: not setDOCKER_UID
:uid
of the user passed todocker run
command. Default: resolved asid -u
BASE_DOCKER_VERSION
(required): impacts the tag of the image built byimage_base
target. The tag is evaluated as:$(BASE_DOCKER_VERSION)-$(OSNAME)
. Default: not setRUST_DOCKER_VERSION
(required): impacts the tag of the image built byimage_rust
target. The tag is evaluated as:$(RUST_DOCKER_VERSION)-$(OSNAME)
. Default: not set
Variables to config packaing using fpm tool:
- (please refer to fpm wiki for more information about the fpm command line options)
FPM_P_NAME
(required): value for fpm's--name
option. Default:$(SRC_VERSION)
FPM_P_VERSION
(required): value for fpm's--version
option. Default: not setFPM_P_INPUT_TYPE
: value for fpm's--input-type
option. Default:dir
FPM_P_OUTPUT_TYPE
: value for fpm's--output-type
option. Default:deb
ifOSNAME=xenial
,rpm
ifOSNAME=centos7
, otherwise - not setFPM_P_OUTPUT_DIR
: value for fpm's--package
option. Default: not setFPM_P_MAINTAINER
: value for fpm's--maintainer
option. Default: not setFPM_P_URL
: value for fpm's--url
option. Default: not setFPM_P_LICENSE
: value for fpm's--license
option. Default: not setFPM_P_DESCRIPTION
: value for fpm's--description
option. Default: not setFPM_ARGS
: string with any fpm arguments to add to the end of the fpm command line. Default: not set- ... (please refer to fpm.mk for more details about fpm related environment variables)
The following variables could be used in call
function and expects some arguments:
check_non_empty
: check if value is non empty and raises error otherwise. Arguments:- value to check
- error message
check_defined
: check if variable is defined (have non empty value) and raises error otherwise- variable name
- (optional) error message
docker_env_value
: resolves the value of someENV
instruction in dockerfile. Arguments:ENV_V_NAME>
is key inENV
instruction<PATH_TO_DOCKERFILE>
path to dockerfile
docker_from_tag
: resolves the tag of the base image defined inFROM
instruction in dockerfile. Arguments:<BASE_IMAGE_NAME>
is name of the base image inFROM
instruction<PATH_TO_DOCKERFILE>
docker_from_version
: resolves the version part of the base image's tag defined inFROM
instruction in dockerfile. It is expected that the tag has the following format:<VERSION>-...
. Arguments:<BASE_IMAGE_NAME>
is name of the base image inFROM
instruction<PATH_TO_DOCKERFILE>