dda-devops-build/doc/DevopsImageBuild.md

114 lines
4.6 KiB
Markdown
Raw Normal View History

2023-06-12 16:41:44 +00:00
# DevopsImageBuild
2023-06-13 06:50:26 +00:00
DevopsImageBuild provides functionality for building container images.
2023-06-12 16:41:44 +00:00
```mermaid
classDiagram
class DevopsImageBuild {
drun() - start your localy build image
dockerhub_login() - login to dockerhub
dockerhub_publish() - publish your image
2023-06-30 11:03:05 +00:00
image() - build image localy. Sources for image build are expected at ./image
initialize_build_dir() - copy current directory & additional files to target. Additional files can be found [here](../src/main/resources/docker)
2023-06-12 16:41:44 +00:00
test() - builds a test image. Sources for image test are expected at ./test
}
```
## Input
| name | description | default |
| ------------------------ | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| name | dedicated name of the build - also used as image name | module |
| module | module name - may result in a hierarchy like name/module | |
| stage | not used in this build | |
| project_root_path | relative path to projects root. Is used to locate the target dir | |
| build_dir_name | name of dir, build is executed in | target |
| build_types | list of special builds used. Value has to be contained["IMAGE"] | [] |
| mixin_types | mixins are orthoganl to builds and represent additional capabilities. Valid Values are ["RELEASE"] | [] |
| credentials_mappings | values for image_dockerhub_user & image_dockerhub_password can be read from gopass | [defaults](#credentials-mapping-defaults) |
| image_dockerhub_user | user to access docker-hub | IMAGE_DOCKERHUB_USER from env or credentials from gopass |
| image_dockerhub_password | password to access docker-hub | IMAGE_DOCKERHUB_PASSWORD from env or credentials from gopass |
| image_tag | tag for publishing the image | IMAGE_TAG from env |
2023-09-29 07:52:37 +00:00
| image_naming | Strategy for calculate the image name. Posible values are [NAME_ONLY,NAME_AND_MODULE] |NAME_ONLY |
2023-06-12 16:41:44 +00:00
### Credentials Mapping defaults
```python
[
{
"gopass_path": "meissa/web/docker.com",
"gopass_field": "login",
"name": "image_dockerhub_user",
},
{
"gopass_path": "meissa/web/docker.com",
"name": "image_dockerhub_password",
},
]
```
## Example Usage
### build.py
```python
2023-06-13 07:18:13 +00:00
from os import environ
2023-06-12 16:41:44 +00:00
from pybuilder.core import task, init
from ddadevops import *
name = 'my-project'
MODULE = 'my-module'
PROJECT_ROOT_PATH = '..'
@init
def initialize(project):
project.build_depends_on("ddadevops>=4.0.0")
input = {
"name": name,
"module": MODULE,
"stage": "notused",
"project_root_path": PROJECT_ROOT_PATH,
"build_types": ["IMAGE"],
"mixin_types": [],
}
build = DevopsImageBuild(project, config)
build.initialize_build_dir()
@task
def image(project):
build = get_devops_build(project)
build.image()
@task
def drun(project):
build = get_devops_build(project)
build.drun()
@task
def test(project):
build = get_devops_build(project)
build.test()
@task
def publish(project):
build = get_devops_build(project)
build.dockerhub_login()
build.dockerhub_publish()
```
### call the build
```bash
pyb image test publish
```
### full example
2023-06-12 16:43:41 +00:00
... can be found [here](../infrastructure/devops-build)