Skip to content

Commit

Permalink
feat(docs): updated usage/build/stapel section (lang:en+ru)
Browse files Browse the repository at this point in the history
Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Dec 19, 2022
1 parent 3af476a commit 0c504a4
Show file tree
Hide file tree
Showing 19 changed files with 3,348 additions and 45 deletions.
8 changes: 8 additions & 0 deletions docs/_data/breadcrumbs.yml
Expand Up @@ -15,6 +15,10 @@ en:
/usage/build_draft: &documentation-usage-build_draft
title: Build
url: usage/build_draft/overview.html
# TODO: delete this temporary element
/usage/build_draft/stapel: &documentation-usage-build_draft-stapel
title: Build
url: usage/build_draft/overview.html
/usage/build/run_in_containers: &documentation-usage-build-run_in_containers
title: Run in containers
url: usage/build/run_in_containers/use_docker_container.html
Expand Down Expand Up @@ -77,6 +81,10 @@ ru:
/usage/build_draft:
<<: *documentation-usage-build_draft
title: Сборка
# TODO: delete this temporary element
/usage/build_draft/stapel:
<<: *documentation-usage-build_draft-stapel
title: Stapel
/usage/build:
<<: *documentation-usage-build
title: Сборка
Expand Down
64 changes: 26 additions & 38 deletions docs/_data/sidebars/_documentation.yml
Expand Up @@ -49,34 +49,28 @@ entries:
- title: Use Kubernetes
url: /usage/build/run_in_containers/use_kubernetes.html

- title: Building images with stapel
- title: Building images with Stapel (UPDATED)
f:
- title: Base image (required)
url: /usage/build/building_images_with_stapel/base_image.html
- title: Overview
url: /usage/build_draft/stapel/overview.html

- title: Adding docker instructions
url: /usage/build/building_images_with_stapel/docker_directive.html
- title: Base image
url: /usage/build_draft/stapel/base.html

- title: Adding source code from git repositories
url: /usage/build/building_images_with_stapel/git_directive.html
url: /usage/build_draft/stapel/git.html

- title: Running assembly instructions
url: /usage/build/building_images_with_stapel/assembly_instructions.html

- title: Reducing image size and speeding up a build by mounts
url: /usage/build/building_images_with_stapel/mount_directive.html
- title: User instructions
url: /usage/build_draft/stapel/instructions.html

- title: Importing from images and artifacts
url: /usage/build/building_images_with_stapel/import_directive.html

- title: Artifacts
url: /usage/build/building_images_with_stapel/artifacts.html
url: /usage/build_draft/stapel/imports.html

- title: Integration with SSH agent
url: /usage/build/building_images_with_stapel/integration_with_ssh_agent.html
- title: Dockerfile instructions
url: /usage/build_draft/stapel/dockerfile.html

- title: Stage Introspection
url: /usage/build/building_images_with_stapel/stage_introspection.html
- title: Reducing image size and speeding up a build by mounts
url: /usage/build/building_images_with_stapel/mounts.html

- title: Deploy
f:
Expand Down Expand Up @@ -246,34 +240,28 @@ entries:
- title: В Kubernetes
url: /usage/build/run_in_containers/use_kubernetes.html

- title: Сборка образов с помощью Stapel
- title: Сборка образов с помощью Stapel (ОБНОВЛЕНИЕ)
f:
- title: Базовый образ
url: /usage/build/building_images_with_stapel/base_image.html
- title: Обзор
url: /usage/build_draft/stapel/overview.html

- title: Использование Docker-инструкций
url: /usage/build/building_images_with_stapel/docker_directive.html
- title: Базовый образ
url: /usage/build_draft/stapel/base.html

- title: Добавление исходного кода из git-репозиториев
url: /usage/build/building_images_with_stapel/git_directive.html

- title: Запуск инструкций сборки
url: /usage/build/building_images_with_stapel/assembly_instructions.html
url: /usage/build_draft/stapel/git.html

- title: Ускорение сборки и уменьшение размера за счёт монтирования
url: /usage/build/building_images_with_stapel/mount_directive.html
- title: Пользовательские инструкции
url: /usage/build_draft/stapel/instructions.html

- title: Импорт из артефактов и образов
url: /usage/build/building_images_with_stapel/import_directive.html
url: /usage/build_draft/stapel/imports.html

- title: Артефакты
url: /usage/build/building_images_with_stapel/artifacts.html
- title: Инструкции Dockerfile
url: /usage/build_draft/stapel/dockerfile.html

- title: Интеграция с SSH-агентом
url: /usage/build/building_images_with_stapel/integration_with_ssh_agent.html

- title: Интроспекция стадий
url: /usage/build/building_images_with_stapel/stage_introspection.html
- title: Ускорение сборки и уменьшение размера за счёт монтирования
url: /usage/build/building_images_with_stapel/mounts.html

- title: Развертывание
f:
Expand Down
64 changes: 64 additions & 0 deletions docs/pages_en/usage/build_draft/stapel/base.md
@@ -0,0 +1,64 @@
---
title: Base image
permalink: usage/build_draft/stapel/base.html
author: Alexey Igrychev <alexey.igrychev@flant.com>
directive_summary: base_image
---

Here's a minimal `werf.yaml`. It describes a _image_ named `example` that is based on a _base image_ named `alpine`:

```yaml
project: my-project
configVersion: 1
---
image: example
from: alpine
```

_Base image_ can be declared with `from`, `fromImage` or `fromArtifact` directive.

## from, fromLatest

The `from` directive defines the name and tag of a _base image_. If absent, tag defaults to `latest`.

```yaml
from: <image>[:<tag>]
```

By default, the assembly process does not depend on actual _base image_ digest in the repository, only on _from_ directive value.
Thus, changing _base image_ locally or in the repository does not matter if _from_ stage is already exists in _storage_.

If you want always build the image with actual _base image_ you should use _fromLatest_ directive.
_fromLatest_ directive allows connecting the assembly process with the _base image_ digest getting from the repository.

```yaml
fromLatest: true
```

> By default, the use of the `fromLatest` directive is not allowed by giterminism (read more about it [here]({{ "usage/project_configuration/giterminism.html" | true_relative_url }}))
## fromImage and fromArtifact

Besides using docker image from a repository, the _base image_ can refer to _image_ or [_artifact_]({{ "usage/build_draft/stapel/imports.html#what-is-an-artifact" | true_relative_url }}), that is described in the same `werf.yaml`.

```yaml
fromImage: <image name>
fromArtifact: <artifact name>
```

If a _base image_ is specific to a particular application,
it is reasonable to store its description with _images_ and _artifacts_ which are used it as opposed to storing the _base image_ in a container registry.

Also, this method can be useful if the stages of _stage conveyor_ are not enough for building the image. You can design your _stage conveyor_.

<a class="google-drawings" href="{{ "images/configuration/base_image2.png" | true_relative_url }}" data-featherlight="image">
<img src="{{ "images/configuration/base_image2_preview.png" | true_relative_url }}" alt="Conveyor with fromImage and fromArtifact stages">
</a>

## fromCacheVersion

The `fromCacheVersion` directive allows managing image reassembly.

```yaml
fromCacheVersion: <arbitrary string>
```
39 changes: 39 additions & 0 deletions docs/pages_en/usage/build_draft/stapel/dockerfile.md
@@ -0,0 +1,39 @@
---
title: Adding docker instructions
permalink: usage/build_draft/stapel/dockerfile.html
author: Alexey Igrychev <alexey.igrychev@flant.com>
directive_summary: docker
---

[Dockerfile instructions](https://docs.docker.com/engine/reference/builder/) 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](https://docs.docker.com/engine/reference/builder/#user)).
* `WORKDIR` to set the working directory (read more [here](https://docs.docker.com/engine/reference/builder/#workdir)).
* `VOLUME` to add mount point (read more [here](https://docs.docker.com/engine/reference/builder/#volume)).
* `ENV` to set the environment variable (read more [here](https://docs.docker.com/engine/reference/builder/#env)).
* `LABEL` to add metadata to an image (read more [here](https://docs.docker.com/engine/reference/builder/#label)).
* `EXPOSE` to inform Docker that the container listens on the specified network ports at runtime (read more [here](https://docs.docker.com/engine/reference/builder/#expose))
* `ENTRYPOINT` to configure a container that will run as an executable (read more [here](https://docs.docker.com/engine/reference/builder/#entrypoint)). 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](https://docs.docker.com/engine/reference/builder/#cmd)). 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](https://docs.docker.com/engine/reference/builder/#healthcheck))

These instructions can be specified in the `docker` config directive.

Here is an example of using docker instructions:

```yaml
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

0 comments on commit 0c504a4

Please sign in to comment.