c87e585918
CI / Load gitea-env.conf to pipeline env (push) Successful in 14s
ci-check Build version 0.1.1 required
ci-docker-build Docker build 0.1.1 OK
ci-docker-push Docker push 0.1.1 OK
ci-docker-tag Tag 0.1.1 OK
CI / Build & Push Artifact (push) Successful in 1m22s
107 lines
3.5 KiB
Markdown
107 lines
3.5 KiB
Markdown
# Docker Registry Setup
|
|
|
|
Pipeline rakentaa Docker-kontin ja pushee sen haluttuun registryyn.
|
|
|
|
---
|
|
|
|
## 1. Konfiguroi `gitea-env.conf`
|
|
|
|
```
|
|
DOCKER_REGISTRY=gitea.app.keskikuja.site/niko # PAKOLLINEN — tyhjä ei käy
|
|
DOCKER_IMAGE_NAME=gitea-ci-library-test-image # PAKOLLINEN
|
|
DOCKER_UI_URL=https://gitea.app.keskikuja.site/niko/-/packages/container/gitea-ci-library-test-image # valinnainen
|
|
```
|
|
|
|
| Kenttä | Pakollinen | Kuvaus |
|
|
|---|---|---|
|
|
| `DOCKER_REGISTRY` | **kyllä** | Registry + mahdollinen organisaatio. **Tyhjä arvo pysäyttää workflow'n virheeseen.** Esim. `gitea.app.keskikuja.site/niko` |
|
|
| `DOCKER_IMAGE_NAME` | **kyllä** | Pelkkä kuvan nimi. Esim. `gitea-ci-library-test-image` |
|
|
| `DOCKER_UI_URL` | ei | Base-URL kontin UI-sivulle (ilman versiota). Workflow liittää perään `/VERSION`. Giteassa muotoa `.../container/<DOCKER_IMAGE_NAME>` |
|
|
|
|
**Koko image-ref:** `${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${VERSION}`
|
|
Esim. `gitea.app.keskikuja.site/niko/gitea-ci-library-test-image:0.1.0`
|
|
|
|
---
|
|
|
|
## 2. Luo PAT (Personal Access Token) Giteassa
|
|
|
|
**Gitea → oma profiili (oikea yläkulma) → Settings → Applications → Manage Access Tokens → Generate New Token**
|
|
|
|
Valitse scope:
|
|
|
|
| Scope | Pääsy |
|
|
|---|---|
|
|
| `package` | **Read and Write** |
|
|
|
|
> Tämä token toimii salasanana `docker login` -komennossa. Muut scopet (kuten `repository`) eivät riitä — konttirekisteri vaatii nimenomaan `package`-scopen.
|
|
|
|
Tokenin arvo näytetään **vain kerran** luomisen yhteydessä. Kopioi se talteen.
|
|
|
|
---
|
|
|
|
## 3. Tallenna PAT repositoryn Secretsiin
|
|
|
|
Nämä ovat kaksi eri paikkaa:
|
|
- **Access Tokenit** (User Settings) = missä luot tokenin
|
|
- **Repository Secrets** (Repository Settings) = minne talletat sen workflow'n käyttöön
|
|
|
|
**Repository → Settings → Actions → Secrets → Add new secret**
|
|
|
|
| Secret | Arvo |
|
|
|---|---|
|
|
| `DOCKER_PASSWORD` | Edellisessä vaiheessa luotu PAT |
|
|
|
|
`DOCKER_USERNAME`-secretiä **ei tarvita**. Workflow käyttää automaattisesti `${{ github.actor }}` (workflowin käynnistäjä).
|
|
|
|
Jos registry vaatii eri käyttäjätunnuksen kuin `github.actor` (esim. Artifactory, Docker Hub), lisää myös:
|
|
|
|
| Secret | Arvo |
|
|
|---|---|
|
|
| `DOCKER_USERNAME` | Registryn käyttäjätunnus |
|
|
|
|
---
|
|
|
|
## 4. Tarkistuslista ennen ajoa
|
|
|
|
- [ ] `DOCKER_REGISTRY` asetettu `gitea-env.conf`issa
|
|
- [ ] `DOCKER_IMAGE_NAME` asetettu `gitea-env.conf`issa
|
|
- [ ] PAT luotu Giteassa scopella `package` Read and Write
|
|
- [ ] `DOCKER_PASSWORD`-secret tallennettu repositoryn Secretsiin (se PAT)
|
|
- [ ] (tarvittaessa) `DOCKER_USERNAME`-secret — oletus `github.actor`
|
|
|
|
---
|
|
|
|
## 5. Esimerkkejä eri registryille
|
|
|
|
### Gitea Packages
|
|
|
|
```
|
|
DOCKER_REGISTRY=gitea.app.keskikuja.site/niko
|
|
DOCKER_IMAGE_NAME=gitea-ci-library-test-image
|
|
DOCKER_UI_URL=https://gitea.app.keskikuja.site/niko/-/packages/container/gitea-ci-library-test-image
|
|
```
|
|
|
|
- PAT scope: `package` Read and Write
|
|
|
|
### Docker Hub
|
|
|
|
```
|
|
DOCKER_REGISTRY=docker.io/library
|
|
DOCKER_IMAGE_NAME=oma-kuva
|
|
DOCKER_UI_URL=https://hub.docker.com/r/library/oma-kuva
|
|
```
|
|
|
|
- Secret `DOCKER_USERNAME` = Docker Hub -käyttäjä
|
|
- Secret `DOCKER_PASSWORD` = Access Token (ei salasana)
|
|
|
|
### Artifactory (kuten legacy Jenkins)
|
|
|
|
```
|
|
DOCKER_REGISTRY=ngdo-docker.artifactorypro.shared.pub.tds.tieto.com
|
|
DOCKER_IMAGE_NAME=microservice-temperature-store
|
|
DOCKER_UI_URL=https://artifactorypro.shared.pub.tds.tieto.com/ui/repos/tree/General/ngdo-docker.artifactorypro.shared.pub.tds.tieto.com/microservice-temperature-store
|
|
```
|
|
|
|
- Secret `DOCKER_USERNAME` = service account -tunnus
|
|
- Secret `DOCKER_PASSWORD` = API-token
|