Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 8662e3eb authored by Dorian Turba's avatar Dorian Turba
Browse files

Merge branch 'trunk'

parents af7b0e5e f2b72be6
No related branches found
No related tags found
No related merge requests found
Pipeline #54089 passed
[tool.bumpversion]
commit = true
config-file = "pyproject.toml"
current_version = "0.2.1"
current_version = "0.3.0"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
replace = "{new_version}"
search = "{current_version}"
......@@ -22,5 +21,3 @@ search = """## [Unreleased]
[[tool.bumpversion.files]]
allow-dirty = true
filename = "README.md"
replace = "{new_version}"
search = "{current_version}"
include:
- project: 'swepy/cicd-templates/release-by-changelog'
ref: '0.4.3'
file: 'templates/release-by-changelog.yml'
- component: $CI_SERVER_FQDN/swepy/cicd-templates/release-by-changelog/release-by-changelog@1.0.0
---
default_stages: [pre-commit]
repos:
# https://pre-commit.com/hooks.html
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-case-conflict # blocking
- id: check-merge-conflict # blocking
- id: detect-private-key # blocking
- id: fix-byte-order-marker # auto-fix
- id: trailing-whitespace # auto-fix
# force respect of Conventional Commits formatting: https://www.conventionalcommits.org/en/v1.0.0/
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: [feat, fix, ci, doc, chore, test] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test]
......@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.3.0] - 2025-03-01
### Added
* Support [inputs](https://docs.gitlab.com/ci/yaml/inputs/):
* stage: Stage of the job
* image_id: Image name and tag of the built image
* context_path: Path to the build context, usually the project
* dockerfile_name: Name of the dockerfile
* docker_host: Docker daemon host URL
* docker_driver: Storage driver used by Docker
* kaniko_options: Additional options to pass to Kaniko for image building
* kaniko_tag: Version tag of the Kaniko executor image
* Variables:
* DOCKERFILE_NAME
* KANIKO_TAG
### Changed
* Variables:
* TARGET_IMAGE -> IMAGE_ID
* PROJECT_PATH -> CONTEXT_PATH
## [0.2.1] - 2024-07-16
* Update CICD
......
......@@ -11,8 +11,7 @@ with.
To set up your environment and install all necessary dependencies:
```sh
pip install --upgrade pip
pip install bump-my-version
pip install --upgrade pip bump-my-version pre-commit
```
### Bump version
......@@ -30,3 +29,17 @@ bump-my-version bump minor
```sh
bump-my-version bump patch
```
## Pre-commit
### install
```shell
pre-commit install
```
### test on all files
```shell
pre-commit run --all-files
```
MIT License
Copyright (c) 2024 Dorian Turba
Copyright (c) 2024-2025 Dorian Turba
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
......@@ -8,51 +8,53 @@ Build a Docker image and push it to the GitLab registry.
## How to use it
### Include the component/template
### Include the component
Add the following to your `.gitlab-ci.yml` file.
As a remote Template (recommended):
```yaml
include:
- remote: 'https://gitlab.com/swepy/cicd-templates/docker-build/-/raw/0.2.1/templates/docker-build.yml'
- component: $CI_SERVER_FQDN/swepy/cicd-templates/docker-build/docker-build@0.3.0
```
As a local Template (if the template is local to the instance):
```yaml
include:
- project: 'swepy/cicd-templates/docker-build'
ref: '0.2.1'
file: 'templates/docker-build.yml'
```
[![Supported by GitLab.com](https://img.shields.io/badge/Supported_by-GitLab.com-orange)](https://gitlab.com)
[![Supported by Frogg.it](https://img.shields.io/badge/Supported_by-Frogg.it-green)](https://froggit.fr/)
As a Component ([beta](https://gitlab.com/gitlab-org/gitlab/-/issues/407556) and if the
component is local to the instance):
### Inputs
```yaml
include:
- component: $CI_SERVER_FQDN/swepy/cicd-templates/docker-build/docker-build@0.2.1
```
You can customize the job by overriding specific inputs.
### Customize job
| Name | Description | Default |
|-------------------|----------------------------------------------------------|-------------------------------------|
| `stage` | Stage of the job. | `test` |
| `image_id` | Image name and tag of the built image. | `$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA` |
| `context_path` | Path to the build context, usually the project. | `.` |
| `dockerfile_name` | Name of the dockerfile. | `Dockerfile` |
| `docker_host` | Docker daemon host URL. | `tcp://docker:2375/` |
| `docker_driver` | Storage driver used by Docker. | `overlay2` |
| `kaniko_options` | Additional options to pass to Kaniko for image building. | `""` |
| `kaniko_tag` | Version tag of the Kaniko executor image. | `v1.23.2-debug` |
You can customize the job by overriding specific keys. For example:
For example:
```yaml
docker-build:
stage: build_img
```yml
include:
- component: $CI_SERVER_FQDN/swepy/cicd-templates/docker-build/docker-build@0.3.0
inputs:
stage: docker_build
context_path: ./project
```
## Variables
You can customize the job by overriding the following variables:
| Name | Description | Default |
|------------------|---------------------------------------|-------------------------------------|
| `DOCKER_HOST` | The path to the Docker Host | `tcp://docker:2375/` |
| `DOCKER_DRIVER` | The name of the Docker driver. | `overlay2` |
| `TARGET_IMAGE` | The nmae and tag of the target image. | `$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA` |
| `PROJECT_PATH` | The tag to apply to the image. | `.` |
| `KANIKO_OPTIONS` | The Kaniko options. | `""` |
| Name | Description | Default |
|-------------------|----------------------------------------------------------|---------------------------------|
| `IMAGE_ID` | Image name and tag of the built image. | `$[[ inputs.image_id ]]` |
| `CONTEXT_PATH` | Path to the build context, usually the project. | `$[[ inputs.context_path ]]` |
| `DOCKERFILE_NAME` | Name of the dockerfile. | `$[[ inputs.dockerfile_name ]]` |
| `DOCKER_HOST` | Docker daemon host URL. | `$[[ inputs.docker_host ]]` |
| `DOCKER_DRIVER` | Storage driver used by Docker. | `$[[ inputs.docker_driver ]]` |
| `KANIKO_OPTIONS` | Additional options to pass to Kaniko for image building. | `$[[ inputs.kaniko_options ]]` |
| `KANIKO_TAG` | Version tag of the Kaniko executor image. | `$[[ inputs.kaniko_tag ]]` |
spec:
inputs:
stage:
description: Stage of the job.
default: build
image_id:
description: Image name and tag of the built image.
default: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
context_path:
description: Path to the build context, usually the project.
default: .
dockerfile_name:
description: Name of the dockerfile.
default: Dockerfile
docker_host:
description: Docker daemon host URL.
default: tcp://docker:2375/
docker_driver:
description: Storage driver used by Docker.
default: overlay2
kaniko_options:
description: Additional options to pass to Kaniko for image building.
default: ""
kaniko_tag:
description: Version tag of the Kaniko executor image.
default: v1.23.2-debug
---
docker_build:
stage: build
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
TARGET_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
PROJECT_PATH: .
KANIKO_OPTIONS: ""
IMAGE_ID: $[[ inputs.image_id ]]
CONTEXT_PATH: $[[ inputs.context_path ]]
DOCKERFILE_NAME: $[[ inputs.dockerfile_name ]]
DOCKER_HOST: $[[ inputs.docker_host ]]
DOCKER_DRIVER: $[[ inputs.docker_driver ]]
KANIKO_OPTIONS: $[[ inputs.kaniko_options ]]
KANIKO_TAG: $[[ inputs.kaniko_tag ]]
image:
name: gcr.io/kaniko-project/executor:v1.14.0-debug
name: gcr.io/kaniko-project/executor:${KANIKO_TAG}
entrypoint: [ "" ]
tags:
- docker
script:
# Kaniko use $CI_REGISTRY_USER and $CI_REGISTRY_PASSWORD to connect to the
# Kaniko uses $CI_REGISTRY_USER and $CI_REGISTRY_PASSWORD to connect to the
# registry
- /kaniko/executor
--context "${PROJECT_PATH}"
--dockerfile "${PROJECT_PATH}/Dockerfile"
--destination "${TARGET_IMAGE}"
--context "${CONTEXT_PATH}"
--dockerfile "${CONTEXT_PATH}/${DOCKERFILE_NAME}"
--destination "${IMAGE_ID}"
${KANIKO_OPTIONS}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment