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
[tool.bumpversion] [tool.bumpversion]
commit = true commit = true
config-file = "pyproject.toml" current_version = "0.3.0"
current_version = "0.2.1"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)" parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
replace = "{new_version}" replace = "{new_version}"
search = "{current_version}" search = "{current_version}"
...@@ -22,5 +21,3 @@ search = """## [Unreleased] ...@@ -22,5 +21,3 @@ search = """## [Unreleased]
[[tool.bumpversion.files]] [[tool.bumpversion.files]]
allow-dirty = true allow-dirty = true
filename = "README.md" filename = "README.md"
replace = "{new_version}"
search = "{current_version}"
include: include:
- project: 'swepy/cicd-templates/release-by-changelog' - component: $CI_SERVER_FQDN/swepy/cicd-templates/release-by-changelog/release-by-changelog@1.0.0
ref: '0.4.3'
file: 'templates/release-by-changelog.yml'
---
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 ...@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [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 ## [0.2.1] - 2024-07-16
* Update CICD * Update CICD
......
...@@ -11,8 +11,7 @@ with. ...@@ -11,8 +11,7 @@ with.
To set up your environment and install all necessary dependencies: To set up your environment and install all necessary dependencies:
```sh ```sh
pip install --upgrade pip pip install --upgrade pip bump-my-version pre-commit
pip install bump-my-version
``` ```
### Bump version ### Bump version
...@@ -30,3 +29,17 @@ bump-my-version bump minor ...@@ -30,3 +29,17 @@ bump-my-version bump minor
```sh ```sh
bump-my-version bump patch bump-my-version bump patch
``` ```
## Pre-commit
### install
```shell
pre-commit install
```
### test on all files
```shell
pre-commit run --all-files
```
MIT License 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal 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. ...@@ -8,51 +8,53 @@ Build a Docker image and push it to the GitLab registry.
## How to use it ## How to use it
### Include the component/template ### Include the component
Add the following to your `.gitlab-ci.yml` file. Add the following to your `.gitlab-ci.yml` file.
As a remote Template (recommended):
```yaml ```yaml
include: 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): [![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/)
```yaml
include:
- project: 'swepy/cicd-templates/docker-build'
ref: '0.2.1'
file: 'templates/docker-build.yml'
```
As a Component ([beta](https://gitlab.com/gitlab-org/gitlab/-/issues/407556) and if the ### Inputs
component is local to the instance):
```yaml You can customize the job by overriding specific inputs.
include:
- component: $CI_SERVER_FQDN/swepy/cicd-templates/docker-build/docker-build@0.2.1
```
### 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 ```yml
docker-build: include:
stage: build_img - component: $CI_SERVER_FQDN/swepy/cicd-templates/docker-build/docker-build@0.3.0
inputs:
stage: docker_build
context_path: ./project
``` ```
## Variables ## Variables
You can customize the job by overriding the following variables: You can customize the job by overriding the following variables:
| Name | Description | Default | | Name | Description | Default |
|------------------|---------------------------------------|-------------------------------------| |-------------------|----------------------------------------------------------|---------------------------------|
| `DOCKER_HOST` | The path to the Docker Host | `tcp://docker:2375/` | | `IMAGE_ID` | Image name and tag of the built image. | `$[[ inputs.image_id ]]` |
| `DOCKER_DRIVER` | The name of the Docker driver. | `overlay2` | | `CONTEXT_PATH` | Path to the build context, usually the project. | `$[[ inputs.context_path ]]` |
| `TARGET_IMAGE` | The nmae and tag of the target image. | `$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA` | | `DOCKERFILE_NAME` | Name of the dockerfile. | `$[[ inputs.dockerfile_name ]]` |
| `PROJECT_PATH` | The tag to apply to the image. | `.` | | `DOCKER_HOST` | Docker daemon host URL. | `$[[ inputs.docker_host ]]` |
| `KANIKO_OPTIONS` | The Kaniko options. | `""` | | `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: docker_build:
stage: build stage: build
variables: variables:
DOCKER_HOST: tcp://docker:2375/ IMAGE_ID: $[[ inputs.image_id ]]
DOCKER_DRIVER: overlay2 CONTEXT_PATH: $[[ inputs.context_path ]]
TARGET_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA DOCKERFILE_NAME: $[[ inputs.dockerfile_name ]]
PROJECT_PATH: . DOCKER_HOST: $[[ inputs.docker_host ]]
KANIKO_OPTIONS: "" DOCKER_DRIVER: $[[ inputs.docker_driver ]]
KANIKO_OPTIONS: $[[ inputs.kaniko_options ]]
KANIKO_TAG: $[[ inputs.kaniko_tag ]]
image: image:
name: gcr.io/kaniko-project/executor:v1.14.0-debug name: gcr.io/kaniko-project/executor:${KANIKO_TAG}
entrypoint: [ "" ] entrypoint: [ "" ]
tags: tags:
- docker - docker
script: 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 # registry
- /kaniko/executor - /kaniko/executor
--context "${PROJECT_PATH}" --context "${CONTEXT_PATH}"
--dockerfile "${PROJECT_PATH}/Dockerfile" --dockerfile "${CONTEXT_PATH}/${DOCKERFILE_NAME}"
--destination "${TARGET_IMAGE}" --destination "${IMAGE_ID}"
${KANIKO_OPTIONS} ${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