Set of Makefiles to simplify software building and packaging process.
Clone into a directory with the main Makefile:
$ git clone https://github.com/aialferov/mk
The setup procedure removes not needed files leaving the "mk" directory with makefiles and a Version file only:
$ make -C mk setup
Now the makefiles can be included into the main Makefile:
include mk/<Makefile>
Where "Makefile" is one of the following:
Provides targets for building an Erlang library. Based on Rebar3 and expects it is located either in the PATH or in the same directory with the main Makefile.
Defined variables:
VERSION
— the library semantic version. Is read from the "src/*.app.src.script" file that is expected to be a Rebar3 Dynamic Configuration file for an Erlang App file with "vsn" key definedGIT_SHA
— first 8 characters of current Git SHA if availableREBAR
— rebar3 executable pathBASE_PATH
— common directory for compilation artefacts and downloaded dependenciesLIB_PATH
— subdirectory of the "BASE_PATH" for the project compiled modules, dependencies download and dependencies compiled modulesPLUGIN_PATH
— subdirectory of the "BASE_PATH" for rebar3 plugins and its compiled modules.
Targets:
compile
— compiles the librarycheck
— runs EUnit based unit testsclean
— removes all the files generated by the "compile" targetdistclean
— removes the "_build" directory recursively, assuming it is the build output directoryshell
— gets into an Erlang shell with all the library and dependencies modules loadeddeps
— downloads the library dependenciesupgrade
— upgrades the library dependenciesgit-release
— creates and pushes a tag named after the current version (uses "VERSION" variable)version
— prints out the full current version, i.e. semantic one and the current Git SHA (uses "VERSION" and "GIT_SHA" variables).
Provides targets for building an Erlang application as a single binary. Includes Erlanglib.mk which makes it also dependent on Rebar3 expecting it either in the PATH or in the same directory with the main Makfile.
Required variables:
PROJECT
— should be set to the project name
Defined variables:
DESTDIR
— intends to be part of the compiled executable installation path. Usually represents root of the installation, that is why should be empty for final installation or set to a directory which is temporary relative root of an upcoming packagePREFIX
— intends to be part of the compiled executable installation path. Usually represents installation destination such as "usr" or "usr/local"BINDIR
— intends to be part of the compiled executable installation path. It is usually "bin" on the most of the systemsBIN_PATH
— compiled executable installation final pathBIN_PATH_IN
— compiled executable output pathERL_PATH
— created Erlang release output path.
Targets:
install
— installs the compiled executableuninstall
— removes the compiled executablerun
— runs the compiled executable with a switch "run"join
— attaches to the running executable Erlang machine with remote shellerlang
— uses R3erlang to create an Erlang release with runtime and the libraries needed to run the compiled executableerlang-clean
— removes recursively the directory with created Erlang releaseerlang-install
— installs Erlang release forwarding "DESTDIR" and "PREFIX" variables to the Makfile generated by R3erlangpackage-ready
— prepares everything for packaging (compiles the executable and creates Erlang release).
Provides targets to simplify Docker image buliding.
Required variables:
USER
— used as Docker IDPROJECT
— used as Docker image nameVERSION
— used Docker image tag
Defined variables:
IMAGE
— full docker image nameIMAGE_LATEST
— full docker image with always "latest" as a tagDOCKER_RUN_ARGS
— all the arguments used for running a containerDOCKER_RUN_ARGS_EXTRA
— additional arguments for docker runDOCKER_BUILD_ARGS
— all the arguments used for building a containerDOCKER_BUILD_ARGS_EXTRA
— additional arguments for docker buildDOCKER_STOP_ARGS
— all the arguments used to stop a running container.
Targets:
docker-build
— build docker imagedocker-push
— push docker images into registrydocker-release —
create "latest" tag and push into registry. Also perform "docker-push"docker-release-local
— create "latest" tagdocker-run
— run image containerdocker-run-d
— run image container in backgrounddocker-stop
— stop running containerdocker-join
— join a running in a container Erlang application with remote shelldocker-shell
— exec shell in a running containerdocker-attach
— attach into a running container (no detach target, to detach the used windows should be closed)docker-logs
— print logs of a running containerdocker-logs-f
— continuosly print logs of a running containerdocker-clean
— remove image of the current versiondocker-distclean
— remove both "latest" and the current version images.
Provides targets to simplify Kubernetes deployments.
Required variables:
PROJECT
— used as deployment nameIMAGE
— used as image to create or upgrade a deployment.
Defined variables:
POD_NAME
— retrieved from a created "PROJECT" deployment using "kubectl".
Targets:
kube-run
— create deployment "PROJECT" using image "IMAGE"kube-join
— remsh to Erlang application in running pod "POD_NAME"kube-shell
— exec shell in running pod "POD_NAME"kube-attach
— attach to running pod "POD_NAME"kube-upgrade
— upgrade deployment "PROJECT" to image "IMAGE"kube-logs
— print running "POD_NAME" pod logskube-logs-f
— same as "kube-logs" but follow log outputkube-delete
— delete deployment "PROJECT".