Skip to content

Commit 340c013

Browse files
committed
Add files to publish oci artifact
Signed-off-by: Manuel Morejon <manuel@mmorejon.io>
1 parent 60dd81a commit 340c013

8 files changed

Lines changed: 287 additions & 1 deletion

File tree

.github/workflows/release.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
7+
env:
8+
IMAGE_NAME: ${{ github.event.repository.name }}
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
release:
15+
name: build and release
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write # needed to write releases
19+
packages: write # needed for ghcr access
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
- name: Setup QEMU
24+
uses: docker/setup-qemu-action@v3
25+
with:
26+
platforms: linux/amd64,linux/arm64
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
- name: Login to GitHub Container Registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Build and push
36+
uses: docker/build-push-action@v6
37+
with:
38+
push: true
39+
context: .
40+
platforms: linux/amd64,linux/arm64
41+
file: ./Dockerfile
42+
tags: |
43+
ghcr.io/mmorejon/${{ env.IMAGE_NAME }}:main

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM scratch
2+
COPY files /

README.en.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# erase-una-vez-5
2+
3+
[![es](https://img.shields.io/badge/Leer_en-Español-blue.svg?style=flat-square)](README.md)
4+
5+
<div align="center">
6+
7+
<img src="./assets/book-cover.jpg" alt="Once Upon a Time Kubernetes Book Cover" width="300"/>
8+
9+
### 📚 OCI Data Volumes
10+
11+
Their function is to generate **"Data-Only" Container Images**: images that do not have an operating system or run anything; they simply serve as a "pen drive" to transport your files to any Kubernetes cluster or Docker environment.
12+
13+
This repository is a practical example created for the book **"Once Upon a Time Kubernetes"**.
14+
15+
👇 **Get the updated 2025 edition here:** 👇
16+
17+
[![Amazon](https://img.shields.io/badge/Amazon-Buy_Paperback-orange?style=for-the-badge&logo=amazon)](https://www.amazon.es/dp/B0F9VPCJ7X)
18+
[![LeanPub](https://img.shields.io/badge/LeanPub-Download_Ebook-blue?style=for-the-badge&logo=leanpub)](https://leanpub.com/once-upon-a-time-kubernetes)
19+
20+
</div>
21+
22+
## ⚡ What makes it special?
23+
24+
* **Docker Simplicity:** It is built using a standard `Dockerfile` and the `scratch` base image.
25+
* **Ultralight:** By using `FROM scratch`, the image contains nothing but your files. Its size is exactly that of your data.
26+
* **Total Compatibility:** Works with any registry (Docker Hub, GHCR, AWS ECR) and tool that supports OCI images.
27+
* **Multi-Architecture:** Configured to automatically generate images compatible with `amd64` and `arm64` via Docker Buildx.
28+
29+
---
30+
31+
## 📦 How to consume the data
32+
33+
Since this image has no operating system (`scratch`), it has no shell (`/bin/sh`) or executables. You cannot run `docker run` in the traditional way. Use it to:
34+
35+
### A) Copy data at build time (Dockerfile)
36+
37+
Ideal for injecting data into other images.
38+
39+
```dockerfile
40+
# 1. Pull our data
41+
FROM ghcr.io/mmorejon/erase-una-vez-5:main AS my-files
42+
43+
# 2. Copy our files to our real application (e.g. Nginx)
44+
FROM nginx:alpine
45+
COPY --from=my-files / /usr/share/nginx/html/
46+
```
47+
48+
Build the image and start the container.
49+
50+
```bash
51+
# Build the image
52+
docker image build --tag server .
53+
54+
# Run the container
55+
docker container run --detach --publish 8080:80 server
56+
```
57+
58+
Access the files included in the image.
59+
60+
```bash
61+
curl http://localhost:8080/example-1.txt
62+
> Érase una vez Kubernetes
63+
```
64+
65+
### B) Use as Volume in Kubernetes (v1.35+)
66+
67+
If your cluster supports the Image Volumes functionality, you can mount it directly. If you do not have a Kubernetes cluster, you can use the exercise repository from the book "Once Upon a Time Kubernetes".
68+
69+
> ℹ️ Reference: For more details about this functionality, see the official announcement in the Kubernetes blog: Support for mounting OCI images as volumes (v1.35 Sneak Peek).
70+
71+
<https://github.com/mmorejon/once-upon-a-time-k8s>
72+
73+
```yaml
74+
apiVersion: v1
75+
kind: Pod
76+
metadata:
77+
name: erase-una-vez-5
78+
spec:
79+
containers:
80+
- name: server
81+
image: nginx:alpine
82+
volumeMounts:
83+
- name: volume
84+
mountPath: /usr/share/nginx/html/
85+
volumes:
86+
- name: volume
87+
image:
88+
reference: ghcr.io/mmorejon/erase-una-vez-5:main
89+
pullPolicy: IfNotPresent
90+
```
91+
92+
To test it, you can use the following command:
93+
94+
```bash
95+
kubectl apply -f https://raw.githubusercontent.com/mmorejon/erase-una-vez-5/refs/heads/main/manifest.yaml
96+
97+
kubectl exec erase-una-vez-5 -- cat /usr/share/nginx/html/example-2.txt
98+
> The scratch image was used to create the OCI artifact.
99+
```
100+
101+
---
102+
103+
## 🤝 Community and Feedback
104+
105+
1.**Has this been useful to you?** Give a **star** to the repository (top right). It helps us reach more engineers.
106+
2. 📚 **Still don't have the book?** Buy the book on Amazon or Leanpub.
107+
108+
<div align="center">
109+
<a href="https://www.amazon.es/dp/B0F9VPCJ7X">
110+
<img src="https://img.shields.io/badge/Amazon-See_price_and_reviews-orange?style=for-the-badge&logo=amazon" />
111+
</a>
112+
</div>

README.md

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,112 @@
1-
# erase-una-vez-5
1+
# erase-una-vez-5
2+
3+
[![English](https://img.shields.io/badge/Read_in-English-blue?style=flat-square)](README.en.md)
4+
5+
<div align="center">
6+
7+
<img src="./assets/book-cover.jpg" alt="Portada Libro Érase una vez Kubernetes" width="300"/>
8+
9+
### 📚 Volúmenes OCI de Datos
10+
11+
Su función es generar **Imágenes de Contenedor "Data-Only"**: imágenes que no tienen sistema operativo ni ejecutan nada, simplemente sirven como un "pendrive" para transportar tus archivos a cualquier clúster de Kubernetes o entorno Docker.
12+
13+
Este repositorio es un ejemplo práctico creado para el libro **"Érase una vez Kubernetes"**.
14+
15+
👇 **Consigue la edición actualizada 2025 aquí:** 👇
16+
17+
[![Amazon](https://img.shields.io/badge/Amazon-Comprar_en_Tapa_Blanda-orange?style=for-the-badge&logo=amazon)](https://www.amazon.es/dp/8409212765)
18+
[![LeanPub](https://img.shields.io/badge/LeanPub-Descargar_Ebook-blue?style=for-the-badge&logo=leanpub)](https://leanpub.com/erase-una-vez-kubernetes)
19+
20+
</div>
21+
22+
## ⚡ ¿Qué tiene de especial?
23+
24+
* **Simplicidad Docker:** Se construye utilizando un `Dockerfile` estándar y la imagen base `scratch`.
25+
* **Ultraligera:** Al usar `FROM scratch`, la imagen no contiene nada más que tus archivos. Su peso es exacto al de tus datos.
26+
* **Compatibilidad Total:** Funciona con cualquier registro (Docker Hub, GHCR, AWS ECR) y herramienta que soporte imágenes OCI.
27+
* **Multi-Arquitectura:** Configurado para generar imágenes compatibles con `amd64` y `arm64` automáticamente mediante Docker Buildx.
28+
29+
---
30+
31+
## 📦 Cómo consumir los datos
32+
33+
Como esta imagen no tiene sistema operativo (`scratch`), no tiene shell (`/bin/sh`) ni ejecutables. No puedes hacer `docker run` de forma tradicional. Úsala para:
34+
35+
### A) Copiar datos en tiempo de construcción (Dockerfile)
36+
37+
Ideal para inyectar datos en otras imágenes.
38+
39+
```dockerfile
40+
# 1. Pull our data
41+
FROM ghcr.io/mmorejon/erase-una-vez-5:main AS my-files
42+
43+
# 2. Copy our files to our real application (e.g. Nginx)
44+
FROM nginx:alpine
45+
COPY --from=my-files / /usr/share/nginx/html/
46+
```
47+
48+
Construye la imagen e inicia el contenedor.
49+
50+
```bash
51+
# Build the image
52+
docker image build --tag server .
53+
54+
# Run the container
55+
docker container run --detach --publish 8080:80 server
56+
```
57+
58+
Accede a los ficheros incluidos en la imagen.
59+
60+
```bash
61+
curl http://localhost:8080/example-1.txt
62+
> Érase una vez Kubernetes
63+
```
64+
65+
### B) Usar como Volumen en Kubernetes (v1.35+)
66+
67+
Si tu clúster admite la funcionalidad Image Volumes, puedes montarla directamente. Si no tienes un clúster de Kubernetes, puedes usar el repositorio de ejercicios del libro Érase una vez Kubernetes.
68+
69+
> ℹ️ Referencia: Para más detalles sobre esta funcionalidad, consulta el anuncio oficial en el blog de Kubernetes: Support for mounting OCI images as volumes (v1.35 Sneak Peek).
70+
71+
<https://github.com/mmorejon/erase-una-vez-k8s>
72+
73+
```yaml
74+
apiVersion: v1
75+
kind: Pod
76+
metadata:
77+
name: erase-una-vez-5
78+
spec:
79+
containers:
80+
- name: server
81+
image: nginx:alpine
82+
volumeMounts:
83+
- name: volume
84+
mountPath: /usr/share/nginx/html/
85+
volumes:
86+
- name: volume
87+
image:
88+
reference: ghcr.io/mmorejon/erase-una-vez-5:main
89+
pullPolicy: IfNotPresent
90+
```
91+
92+
Para probarlo, puedes usar el siguiente comando:
93+
94+
```bash
95+
kubectl apply -f https://raw.githubusercontent.com/mmorejon/erase-una-vez-5/refs/heads/main/manifest.yaml
96+
97+
kubectl exec erase-una-vez-5 -- cat /usr/share/nginx/html/example-1.txt
98+
> Érase una vez Kubernetes
99+
```
100+
101+
---
102+
103+
## 🤝 Comunidad y Feedback
104+
105+
1.**¿Te ha sido útil?** Dale una **estrella** al repositorio (arriba a la derecha). Nos ayuda a llegar a más ingenieros.
106+
2. 📚 **¿Aún no tienes el libro?** Compra el libro en Amazon o Leanpub.
107+
108+
<div align="center">
109+
<a href="https://www.amazon.es/dp/8409212765">
110+
<img src="https://img.shields.io/badge/Amazon-Ver_Precio_y_Opiniones-orange?style=for-the-badge&logo=amazon" />
111+
</a>
112+
</div>

assets/book-cover.jpg

324 KB
Loading

files/example-1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Érase una vez Kubernetes

files/example-2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The scratch image was used to create the OCI artifact.

manifest.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: erase-una-vez-5
5+
spec:
6+
containers:
7+
- name: server
8+
image: nginx:alpine
9+
volumeMounts:
10+
- name: volume
11+
mountPath: /usr/share/nginx/html/
12+
volumes:
13+
- name: volume
14+
image:
15+
reference: ghcr.io/mmorejon/erase-una-vez-5:main
16+
pullPolicy: IfNotPresent

0 commit comments

Comments
 (0)