Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 2.96 KB

dockerfile.md

File metadata and controls

39 lines (31 loc) · 2.96 KB
title permalink author directive_summary
Adding docker instructions
usage/build_draft/stapel/dockerfile.html
Alexey Igrychev <alexey.igrychev@flant.com>
docker

Dockerfile instructions can be divided into two groups: build-time instructions and other instructions that effect on an image manifest. Build-time instructions do not make sense in a werf build process. Therefore, werf supports only following instructions:

  • USER to set the user name (or UID) and optionally the user group (or GID) (read more here).
  • WORKDIR to set the working directory (read more here).
  • VOLUME to add mount point (read more here).
  • ENV to set the environment variable (read more here).
  • LABEL to add metadata to an image (read more here).
  • EXPOSE to inform Docker that the container listens on the specified network ports at runtime (read more here)
  • ENTRYPOINT to configure a container that will run as an executable (read more here). How stapel builder processes CMD and ENTRYPOINT is covered [here]({{ "/usage/build/build_process.html#how-the-stapel-builder-processes-cmd-and-entrypoint" | true_relative_url }}).
  • CMD to provide default arguments for the ENTRYPOINT to configure a container that will run as an executable (read more here). How stapel builder processes CMD and ENTRYPOINT is covered [here]({{ "/usage/build/build_process.html#how-the-stapel-builder-processes-cmd-and-entrypoint" | true_relative_url }}).
  • HEALTHCHECK to tell Docker how to test a container to check that it is still working (read more here)

These instructions can be specified in the docker config directive.

Here is an example of using docker instructions:

docker:
  WORKDIR: /app
  CMD: ["python", "./index.py"]
  EXPOSE: '5000'
  ENV:
    TERM: xterm
    LC_ALL: en_US.UTF-8

Defined docker instructions are applied on the last stage called docker_instructions. Thus, instructions do not affect other stages, ones just will be applied to a built image.

If need to use special environment variables in build-time of your application image, such as TERM environment, you should use a [base image]({{ "usage/build_draft/stapel/base.html" | true_relative_url }}) with these variables.

Tip: you can also implement exporting environment variables right in [user stage]({{ "usage/build/building_images_with_stapel/assembly_instructions.html#what-are-user-stages" | true_relative_url }}) instructions