A docker image that can (and probably should) be used by all containers that will run microservices for To-Increase.
Using the base image
Just base your image on this one:
Then use it like you normally would.
There are two versions: one 'nodejs' branch for nodejs services and the default which is more generic. The latter uses envconsul to inject env vars.
Running the container
This image uses a predefined entrypoint that will execute CMD arguments you provide. So, in order to execute ls with two additional arguments, you can provide a CMD target like this:
CMD ["/bin/ls", "-l", "-h" ]
You can add packages. Don't forget to clean the cache though. An example to add wget:
RUN apk update \ && apk add wget \ && rm -rf /var/cache/apk/*
Optional: Health checks.
You can define a health check for your service. If the health check detects a failure, the whole container will be killed. A check can be configured in the following way:
ADD health-check /bin/health-check
The health check itself is just a simple script. An example:
$ cat /bin/health-check #!/bin/sh # On a server error code, curl exits with an error code of 22 curl --silent --fail http://localhost:8080/health
Optionally, you can define the interval for the check as well by overriding the settings.profile
ADD settings.profile /etc/settings.profile
The contents of the settings.profile:
$ cat /bin/settings.profile 1 # Health check interval in seconds HEALTH_CHECK_INTERVAL=30
The image is available at quay.io/toincrease/docker-base-image
The source code can be found at bitbucket