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 1ee56915 authored by Dorian Turba's avatar Dorian Turba
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #35650 passed
include:
- project: 'swepy/cicd-templates/release-by-changelog'
ref: '0.4.1'
file: 'templates/release-by-changelog.yml'
# Changelog
All notable changes to this job will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.1.0] - 2024-06-01
* Initial version
# Contributing to Docker Build
## Useful Commands for Development
This project relies on several commands to manage dependencies and versioning
effectively. Here's a breakdown of the most important commands you should be familiar
with:
### Installation
To set up your environment and install all necessary dependencies:
```sh
pip install --upgrade pip
pip install bump-my-version
```
### Bump version
To bump the version of the project, use the following command:
```sh
bump-my-version bump major
```
```sh
bump-my-version bump minor
```
```sh
bump-my-version bump patch
```
LICENSE 0 → 100644
MIT License
Copyright (c) 2024 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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Docker Build
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://lab.frogg.it/swepy/cicd-templates/docker-build/-/blob/main/LICENSE)
## Objective
Build a Docker image and push it to the GitLab registry.
## How to use it
### Include the component/template
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/docker-build@0.1.0/docker-build.yml'
```
As a local Template (if the template is local to the instance):
```yaml
include:
- project: 'swepy/cicd-templates/docker-build'
ref: '0.1.0'
file: 'templates/docker-build.yml'
```
As a Component ([beta](https://gitlab.com/gitlab-org/gitlab/-/issues/407556) and if the
component is local to the instance):
```yaml
include:
- component: $CI_SERVER_FQDN/swepy/cicd-templates/docker-build/docker-build@0.1.0
```
### Customize job
You can customize the job by overriding specific keys. For example:
```yaml
docker-build:
stage: build_img
```
## Variables
You can customize the job by overriding the following variables:
| Name | Description | Default |
|----------------------|--------------------------------|---------------------------|
| `DOCKER_TLS_CERTDIR` | The path to the Docker TLS dir | `""` |
| `IMAGE_NAME` | The name of the image. | `$CI_PROJECT_NAME` |
| `PROJECT_PATH` | The path to the project. | `.` |
| `TAG` | The tag to apply to the image. | `$CI_COMMIT_SHA` |
| `TARGET_IMAGE` | The target image name. | `$CI_REGISTRY_IMAGE:$TAG` |
files:
template: templates/docker-build.yml
documentation: README.md
changelog: CHANGELOG.md
data:
description: "Builds a Docker image and pushes it to the GitLab registry."
icon: 🐳
labels:
- Gitlab
- Utilities
- Build
license: MIT
deprecated: False
[tool.bumpversion]
commit = true
config-file = "pyproject.toml"
current_version = "0.1.0"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
replace = "{new_version}"
search = "{current_version}"
serialize = [
"{major}.{minor}.{patch}",
]
tag = false
[[tool.bumpversion.files]]
filename = "CHANGELOG.md"
replace = """## [Unreleased]
## [{new_version}] - {now:%Y-%m-%d}
"""
search = """## [Unreleased]
"""
[[tool.bumpversion.files]]
allow-dirty = true
filename = "README.md"
replace = "{new_version}"
search = "{current_version}"
docker_build:
stage: build
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
TAG: $CI_COMMIT_SHA
IMAGE_NAME: $CI_PROJECT_NAME
TARGET_IMAGE: $CI_REGISTRY_IMAGE:$TAG
PROJECT_PATH: .
services:
- name: docker:dind
entrypoint: [ "env", "-u", "DOCKER_HOST" ]
command: [ "dockerd-entrypoint.sh" ]
tags:
- docker
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build -t $IMAGE_NAME $PROJECT_PATH
- docker tag $IMAGE_NAME $TARGET_IMAGE
- docker push $TARGET_IMAGE
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