Fix/ci container manual start (#20)
CI Main / Bats tests (push) Successful in 1m34s
acc-tests Link to Cucumber reports
CI Main / Cucumber tests (push) Successful in 51s
CI Main / Load example-gitea-env.conf to pipeline env (push) Successful in 21s
CI Main / Check existing artifact (push) Successful in 13s
unit-tests Link to Bats reports
ci-docker-build-push Docker build & push 0.2.7 OK
CI Main / Build & Push Docker (push) Successful in 41s
CI Main / Report Summary (push) Successful in 6s
CI Main / Move provider version tag (push) Successful in 12s
CI Main / Bats tests (push) Successful in 1m34s
acc-tests Link to Cucumber reports
CI Main / Cucumber tests (push) Successful in 51s
CI Main / Load example-gitea-env.conf to pipeline env (push) Successful in 21s
CI Main / Check existing artifact (push) Successful in 13s
unit-tests Link to Bats reports
ci-docker-build-push Docker build & push 0.2.7 OK
CI Main / Build & Push Docker (push) Successful in 41s
CI Main / Report Summary (push) Successful in 6s
CI Main / Move provider version tag (push) Successful in 12s
Co-authored-by: moilanik <niko.moilanen@tietoevry.com> Reviewed-on: #20
This commit was merged in pull request #20.
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
---
|
||||
name: ci-container-build
|
||||
description: |
|
||||
Creating or modifying CI container build workflows. Activates when consumer
|
||||
needs to build a custom CI container image (multi-tool image for tests,
|
||||
linting, validation) that is pushed to a container registry for use in
|
||||
other pipeline jobs.
|
||||
activation-gate: |
|
||||
User mentions CI container, custom CI image, ci-container-build, Dockerfile
|
||||
for CI tools, multi-tool container, or needs to build/push a container that
|
||||
other CI jobs will use as their runtime environment.
|
||||
category: ci
|
||||
impact: high
|
||||
---
|
||||
|
||||
# CI Container Build — Template
|
||||
|
||||
Template jolla consumer luo oman CI-kontin build-workflown.
|
||||
Kontti sisältää useamman työkalun yhdistelmän (esim. helm + kubeconform + xsltproc),
|
||||
jota muut jobit käyttävät ajonaikaisena ympäristönä.
|
||||
|
||||
## Rakenne
|
||||
|
||||
Vain `workflow_dispatch` — **ei automaattista buildausta koskaan**. Kontti buildataan
|
||||
manuaalisesti Gitea Actions UI:sta. Tiedoston ilmestyessä main-haaraan workflow näkyy
|
||||
välittömästi Actions-tabissa ajettavana.
|
||||
|
||||
Build-prosessi lataa ensin `config-provider.yml`:llä `DOCKER_REGISTRY`:n
|
||||
conf-tiedostosta, sitten buildaa ja puskaa kontin.
|
||||
|
||||
Kun kontti on pushattu registryyn, se on muiden pipeline-jobien käytettävissä
|
||||
`latest`-tägillä — rebuild = käyttöönotto. Mitään versioviittauksia ei tarvitse
|
||||
päivittää.
|
||||
|
||||
## Nimeäminen
|
||||
|
||||
CI-kontin build-workflow noudattaa samaa nimeämiskonventiota kuin muutkin
|
||||
tiedostot `.gitea/workflows/`-kansiossa:
|
||||
|
||||
```
|
||||
<komponentti>.ci-feature.yml ← feature-haaran reititin
|
||||
<komponentti>.ci-main.yml ← main-haaran reititin
|
||||
<komponentti>.<testityyppi>.yml ← yksittäinen testi tai operaatio
|
||||
<komponentti>.ci-container-build-<kontti>.yml ← CI-kontin build-workflow
|
||||
<komponentti>.gitea-env.conf ← komponenttikohtainen konfiguraatio
|
||||
```
|
||||
|
||||
Single repossa `<komponentti>` jätetään pois — tiedostot ovat suoraan `ci-feature.yml`,
|
||||
`ci-main.yml`, `<testityyppi>.yml`, `ci-container-build-<kontti>.yml`.
|
||||
|
||||
Monorepossa prefiksi pitää komponentin tiedostot yhdessä: `ls <komponentti>.*` löytää kaikki
|
||||
kerralla. **Olemassaolevia prefiksejä ei saa poistaa.**
|
||||
|
||||
Esimerkkejä:
|
||||
```
|
||||
.gitea/workflows/chart.ci-container-build-helm.yml
|
||||
.gitea/workflows/api.ci-container-build-node.yml
|
||||
.gitea/workflows/ci-container-build-bats.yml ← single repo
|
||||
```
|
||||
|
||||
## Template
|
||||
|
||||
> **Korvaa kaikki `__SUURAAKKOSET__`-placeholderit projektin todellisilla arvoilla.**
|
||||
> Ainoastaan `${{ ... }}`-syntaksilla merkityt Gitea Actions -muuttujat ovat ajonaikaisia
|
||||
> eikä niitä korvata.
|
||||
|
||||
Luo `.gitea/workflows/__KOMPONENTTI__.ci-container-build-__KONTTI__.yml`
|
||||
(single repo: `ci-container-build-__KONTTI__.yml`):
|
||||
|
||||
```yaml
|
||||
name: CI Container Build & Push
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
config_path:
|
||||
required: true
|
||||
type: string
|
||||
description: 'Polku .gitea-env.conf-tiedostoon (esim. .gitea/workflows/chart.gitea-env.conf)'
|
||||
dockerfile_path:
|
||||
required: true
|
||||
type: string
|
||||
description: 'Polku Dockerfileen (esim. ci-helm.Dockerfile)'
|
||||
image_name:
|
||||
required: true
|
||||
type: string
|
||||
description: 'Kontin nimi ilman registry-polkua (esim. ci-helm)'
|
||||
tag:
|
||||
required: true
|
||||
type: string
|
||||
default: 'latest'
|
||||
description: 'Image-tägi'
|
||||
|
||||
jobs:
|
||||
load-config:
|
||||
uses: __OWNER__/gitea-ci-library/.gitea/workflows/config-provider.yml@v1
|
||||
secrets: inherit
|
||||
with:
|
||||
config_path: ${{ inputs.config_path }}
|
||||
|
||||
build-push:
|
||||
needs: [load-config]
|
||||
uses: __OWNER__/gitea-ci-library/.gitea/workflows/ci-container-build-push.yml@v1
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ needs.load-config.outputs.env_json }}
|
||||
dockerfile_path: ${{ inputs.dockerfile_path }}
|
||||
image_name: ${{ inputs.image_name }}
|
||||
tag: ${{ inputs.tag }}
|
||||
```
|
||||
|
||||
### Käyttö
|
||||
|
||||
**Gitea Actions UI:sta** (heti kun tiedosto on main-haarassa):
|
||||
|
||||
```
|
||||
Gitea → Actions → CI Container Build & Push → Run workflow
|
||||
|
||||
config_path: .gitea/workflows/__KOMPONENTTI__.gitea-env.conf
|
||||
dockerfile_path: ci-__TYÖKALU__.Dockerfile
|
||||
image_name: ci-__TYÖKALU__
|
||||
tag: latest
|
||||
```
|
||||
|
||||
### Dockerfile
|
||||
|
||||
Dockerfile yhdistää tarvitut työkalut yhteen konttiin. Molemmat tavat kelpaavat:
|
||||
|
||||
```dockerfile
|
||||
# Tapa A: COPY --from toisesta imagesta
|
||||
FROM __BASE_IMAGE__:__VERSION__
|
||||
COPY --from=__SOURCE_IMAGE__:__VERSION__ /path/to/binary /usr/local/bin/
|
||||
RUN apk add --no-cache __PAKETIT__
|
||||
|
||||
# Tapa B: curl-lataus (normaali Dockerfilessa)
|
||||
FROM __BASE_IMAGE__:__VERSION__
|
||||
RUN apk add --no-cache curl __PAKETIT__ && \
|
||||
curl -fsSL __URL__/__BINARY__.tar.gz | tar xz -C /usr/local/bin && \
|
||||
apk del curl
|
||||
```
|
||||
|
||||
`COPY --from` on kevyempi (ei curl-asennusta). `curl` on selkeämpi kun binääri
|
||||
tulee suoraan GitHub Releasesista tai vastaavasta.
|
||||
|
||||
## Mitä EI kannata tehdä
|
||||
|
||||
- Älä lisää `workflow_call`-triggariä — CI-konttia ei koskaan buildata automaattisesti
|
||||
- Älä poista `<komponentti>.`-prefiksiä olemassaolevista tiedostoista — ne kuuluvat monorepo-nimeämiskonventioon
|
||||
- Älä sisällytä CI-konttiin mitään sovelluskoodia — vain työkalut
|
||||
@@ -108,15 +108,15 @@ shellin käyttäytyminen vaihtelee.
|
||||
|
||||
1. **Julkiset registry-kontit kiinteällä versiolla** — `alpine/helm:3.19.0`, `node:22`, `maven:3.9-eclipse-temurin-21`.
|
||||
Toistettavuus ja turvallisuus eivät saa riippua ulkoisesta `latest`:sta
|
||||
2. **Projektin omat CI-kontit `latest`-tägillä** — buildattu `ci-container-build-push.yml`:llä.
|
||||
2. **Projektin omat CI-kontit `latest`-tägillä** — buildattu `ci-container-build-<kontti>.yml`:llä.
|
||||
Kontin build-pipeline päivittää `latest`:n automaattisesti. Rebuild = käyttöönotto
|
||||
kaikissa pipelineissa ilman versioviittauksien päivittelyä.
|
||||
`latest` on näille paras käytäntö, ei kompromissi
|
||||
3. **Ei koskaan `curl`-latauksia CI-ajon sisällä** — työkalujen asennus CI-stepeissä hidastaa,
|
||||
epäluotettavaa, ja vaikeuttaa toistettavuutta
|
||||
|
||||
Pre-buildattu kontti rakennetaan minimaalisella Dockerfilella, joka kopioi tarvitut binäärit
|
||||
perusimagesta ja asentaa vain välttämättömät paketit.
|
||||
CI-kontin build-workflow'n template: [skills/ci-container-build/SKILL.md](../ci-container-build/SKILL.md) — sisältää
|
||||
valmiin `ci-container-build-<kontti>.yml`-pohjan jossa `workflow_dispatch`-tuki manuaaliajoon.
|
||||
|
||||
## 5. Raporttitasot
|
||||
|
||||
@@ -174,14 +174,15 @@ Tiedostonimet `.gitea/workflows/`-kansiossa noudattavat yhtenäistä rakennetta,
|
||||
tiedostot löytyvät nopeasti ja niiden rooli on selvillä:
|
||||
|
||||
```
|
||||
<komponentti>.ci-feature.yml ← feature-haaran reititin
|
||||
<komponentti>.ci-main.yml ← main-haaran reititin
|
||||
<komponentti>.<testityyppi>.yml ← yksittäinen testi tai operaatio
|
||||
<komponentti>.gitea-env.conf ← komponenttikohtainen konfiguraatio
|
||||
<komponentti>.ci-feature.yml ← feature-haaran reititin
|
||||
<komponentti>.ci-main.yml ← main-haaran reititin
|
||||
<komponentti>.<testityyppi>.yml ← yksittäinen testi tai operaatio
|
||||
<komponentti>.ci-container-build-<kontti>.yml ← CI-kontin build-workflow
|
||||
<komponentti>.gitea-env.conf ← komponenttikohtainen konfiguraatio
|
||||
```
|
||||
|
||||
Single repossa `<komponentti>` jätetään pois — tiedostot ovat suoraan `ci-feature.yml`,
|
||||
`ci-main.yml`, `<testityyppi>.yml`.
|
||||
`ci-main.yml`, `<testityyppi>.yml`, `ci-container-build-<kontti>.yml`.
|
||||
|
||||
Monorepossa prefiksi pitää komponentin tiedostot yhdessä: `ls <komponentti>.*` löytää kaikki
|
||||
kerralla.
|
||||
|
||||
Reference in New Issue
Block a user