Merge pull request #53 from ublue-os/tepene/51_build-args

chore(main): include latest changes
This commit is contained in:
Stephan Lüscher 2024-05-27 18:47:09 +02:00 committed by GitHub
commit bb80ee34fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 113 additions and 61 deletions

View file

@ -1,19 +1,25 @@
aggrid aggrid
AKMODS
CHACHA CHACHA
configmap configmap
Containerfile Containerfile
containerignore containerignore
devcontainer devcontainer
devcontainers devcontainers
dialtimeout
dotenv dotenv
ENDCOLOR ENDCOLOR
ensurepath ensurepath
envsubst envsubst
filepicker filepicker
forwardingtimeouts
getent getent
gitmessage gitmessage
HHMMSS
hostvars hostvars
humanfriendly humanfriendly
idleconntimeout
idletimeout
keygen keygen
LAZYGIT LAZYGIT
lightspeed lightspeed
@ -30,10 +36,13 @@ notranslate
pipx pipx
posix posix
Proto Proto
readtimeout
redirections redirections
refreshable refreshable
rvproxy rvproxy
serverstransport serverstransport
serverstransports
silverblue
traefik traefik
ublue ublue
varnames varnames
@ -41,3 +50,4 @@ venvs
VIRTUALENVS VIRTUALENVS
wantlist wantlist
websecure websecure
writetimeout

View file

@ -1,3 +1,6 @@
--- ---
forge_container_name: "{{ forge_registry_url }}/{{ forge_git_repository_url | regex_search('(?<=/)[^/]+(?=\\.git)') }}"
forge_container_tag: "{{ ansible_date_time.date }}_{{ ansible_date_time.time | replace(':','')}}"
forge_container_file: "Containerfile" forge_container_file: "Containerfile"
forge_container_format: "oci" forge_container_format: "oci"
forge_container_extra_args: []

View file

@ -1,5 +1,5 @@
--- ---
# git variables # git variables
forge_git_repository_url: "https://github.com/ublue-os/bluefin.git" forge_git_repository_url: ""
forge_git_repository_destination: "{{ forge_data_volume_mountpoint }}/data/bluefin" forge_git_repository_destination: ""
forge_git_repository_version: "main" forge_git_repository_version: "main"

View file

@ -36,19 +36,19 @@
changed_when: false changed_when: false
become: true become: true
- name: Create example extra-vars configuration file - name: Create example directory
ansible.builtin.copy: ansible.builtin.file:
dest: "{{ forge_data_volume_mountpoint }}/forge_example_vars.yml" path: "{{ forge_data_volume_mountpoint }}/examples/"
content: | state: directory
## ublue-os forge extra-vars example configuration mode: "0755"
## For more details got to https://github.com/ublue-os/forge/blob/main/docs/variables.md
--- - name: Create example configuration files
{% for item in __vars_used %} ansible.builtin.template:
{{ item }}: {{ lookup('ansible.builtin.vars', item) }} src: "{{ item }}"
{% endfor %} dest: "{{ forge_data_volume_mountpoint }}/examples/{{ item | regex_search(__regex_search) }}"
backup: true backup: true
owner: "{{ ansible_facts.env.USER }}" owner: "{{ ansible_facts.env.USER }}"
mode: "0644" mode: "0644"
with_fileglob: "files/examples/*"
vars: vars:
__vars_used: "{{ lookup('ansible.builtin.varnames', __regex_search, wantlist=true) }}" __regex_search: "[^\/]+$"
__regex_search: ^forge_(?!data).+

View file

@ -0,0 +1,11 @@
## ublue-os forge example configuration for bluefin
## For more details got to https://github.com/ublue-os/forge/blob/main/docs/variables.md
---
forge_git_repository_url: https://github.com/ublue-os/bluefin.git
forge_git_repository_destination: "{{ forge_data_volume_mountpoint }}/data/bluefin"
forge_container_extra_args:
- --build-arg="BASE_IMAGE_NAME=silverblue"
- --build-arg="IMAGE_FLAVOR=main"
- --build-arg="AKMODS_FLAVOR=main"
- --build-arg="FEDORA_MAJOR_VERSION=39"
- --build-arg="TARGET_BASE=bluefin"

View file

@ -8,34 +8,59 @@
name: debug_forge_vars name: debug_forge_vars
tasks: tasks:
- name: Build and push image to registry - name: Build and upload container image
containers.podman.podman_image: containers.podman.podman_image:
name: "{{ forge_git_repository_url | regex_search(__regex_search) }}" name: "{{ forge_container_name }}"
tag: latest tag: latest
path: "{{ forge_git_repository_destination }}" path: "{{ forge_git_repository_destination }}"
build: build:
file: "{{ forge_container_file | default('Containerfile') }}" file: "{{ forge_container_file }}"
format: "{{ forge_container_format | default('oci') }}" format: "{{ forge_container_format }}"
extra_args: "{{ forge_container_extra_args | join(' ') }}"
pull: false pull: false
push: true push: true
push_args: async: 900
dest: "{{ forge_registry_url }}"
vars:
__regex_search: (?<=/)[^/]+(?=\.git)
async: 1800
poll: 0 poll: 0
register: __podman_image register: __podman_image
- name: Waiting for container build to finish - name: Waiting for container build and upload to finish
ansible.builtin.async_status: ansible.builtin.async_status:
jid: "{{ __podman_image.ansible_job_id }}" jid: "{{ __podman_image.ansible_job_id }}"
register: __job_result register: __job_result
until: __job_result.finished until: __job_result.finished
retries: 1800 retries: 900
delay: 1 delay: 1
- name: INFO | Status from build and push - name: INFO | Result from container image build
ansible.builtin.debug: ansible.builtin.debug:
msg: msg:
- "{{ __job_result.actions | to_nice_yaml(indent=2) }}" - "{{ __job_result.actions | to_nice_yaml(indent=2) }}"
- "{{ __job_result.image | to_nice_yaml(indent=2) }}" - "{{ __job_result.image | to_nice_yaml(indent=2) }}"
- name: Add additional tag to container image
containers.podman.podman_tag:
image: "{{ forge_container_name }}:latest"
target_names:
- "{{ forge_container_name }}:{{ forge_container_tag }}"
- name: Push additional container image tag to registry
containers.podman.podman_image:
name: "{{ forge_container_name }}"
tag: "{{ forge_container_tag }}"
pull: false
push: true
async: 15
poll: 0
register: __podman_image
- name: Waiting for additional container image tag push to finish
ansible.builtin.async_status:
jid: "{{ __podman_image.ansible_job_id }}"
register: __job_result
until: __job_result.finished
retries: 15
delay: 1
- name: INFO | Result from additional container image tag push
ansible.builtin.debug:
msg: "{{ __job_result.actions | to_nice_yaml(indent=2) }}"

View file

@ -14,7 +14,9 @@ ANSIBLE_EXTRA_VARS = None
async def load_configuration_file() -> None: async def load_configuration_file() -> None:
global ANSIBLE_EXTRA_VARS global ANSIBLE_EXTRA_VARS
result = await local_file_picker( result = await local_file_picker(
directory="/data", multiple=False, file_name_filter=".yml" directory="/data",
multiple=False,
# file_name_filter=".yml", # TODO: limit to yml files but make sure folders are visible as well
) )
file_path = result[0] file_path = result[0]
with open(file_path, "r") as file: with open(file_path, "r") as file:

View file

@ -6,7 +6,7 @@ from utils.registry import DockerRegistry
## TODO: this should be async but I currently don't know how to implement this without button press ## TODO: this should be async but I currently don't know how to implement this without button press
def get_image_info() -> pandas.DataFrame: def get_image_info() -> pandas.DataFrame:
data = pandas.DataFrame(columns=["image_name", "tag", "size"]) data = pandas.DataFrame(columns=["image", "tag", "size"])
try: try:
registry = DockerRegistry() registry = DockerRegistry()
all_image_info = registry.get_all_image_info() all_image_info = registry.get_all_image_info()
@ -24,8 +24,10 @@ def get_image_info() -> pandas.DataFrame:
lambda layers: sum(layer["size"] for layer in layers) lambda layers: sum(layer["size"] for layer in layers)
) )
) )
data = data[["image_name", "name", "size"]].rename( data = (
columns={"image_name": "image", "name": "tag", "size": "size"} data[["image_name", "name", "size"]]
.rename(columns={"image_name": "image", "name": "tag", "size": "size"})
.sort_values(by=["image", "tag"], ascending=False)
) )
data["size"] = data["size"].apply(humanize.naturalsize) data["size"] = data["size"].apply(humanize.naturalsize)
return data return data
@ -39,4 +41,7 @@ def content() -> None:
with ui.card().classes("w-full"): with ui.card().classes("w-full"):
ui.label("Image Overview").classes("text-h5") ui.label("Image Overview").classes("text-h5")
data = get_image_info() data = get_image_info()
ui.table.from_pandas(df=data).classes("w-full") with ui.table.from_pandas(df=data).classes("w-full") as table:
table.columns[0]["sortable"] = True
table.columns[1]["sortable"] = True
table.columns[2]["sortable"] = True

View file

@ -35,9 +35,10 @@ def frame(
with ui.grid(columns=3).classes("w-full gap-0"): with ui.grid(columns=3).classes("w-full gap-0"):
with ui.row(wrap=False).classes("col-span-1 justify-start"): with ui.row(wrap=False).classes("col-span-1 justify-start"):
menu() menu()
ui.image(source=f"{project_root}/pages/assets/ublue-mini.svg").props( with ui.link(target="/"):
"width=33px hight=auto" ui.image(
) source=f"{project_root}/pages/assets/ublue-mini.svg"
).props("width=33px hight=auto")
ui.label(text="Forge").classes("text-h5") ui.label(text="Forge").classes("text-h5")
with ui.row(wrap=False).classes("col-span-1 justify-center"): with ui.row(wrap=False).classes("col-span-1 justify-center"):
ui.label(text=navigation_title).classes("text-h5") ui.label(text=navigation_title).classes("text-h5")

View file

@ -41,21 +41,24 @@ ln -s $FORGE_POD_DATA_DIR $HOME/ublue-os_forge-data
With this the data folder would be available in your home directory under `~/ublue-os_forge-data` With this the data folder would be available in your home directory under `~/ublue-os_forge-data`
In that folder you will find an example configuration similar to this: In that folder you will find an **examples** folder with example configurations similar to this:
```yaml ```yaml
## ublue-os forge extra-vars example configuration ## ublue-os forge example configuration
## For more details got to https://github.com/ublue-os/forge/blob/main/docs/variables.md ## For more details got to https://github.com/ublue-os/forge/blob/main/docs/variables.md
--- ---
forge_git_repository_url: https://github.com/ublue-os/bluefin.git forge_git_repository_url: https://github.com/ublue-os/bluefin.git
forge_git_repository_destination: /var/home/stephan/.local/share/containers/storage/volumes/ublue-os_forge-data/_data/data/bluefin forge_git_repository_destination: "/var/home/stephan/.local/share/containers/storage/volumes/ublue-os_forge-data/_data/data/bluefin"
forge_git_repository_version: main forge_container_extra_args:
forge_registry_url: registry.ublue.local - --build-arg="BASE_IMAGE_NAME=silverblue"
- --build-arg="IMAGE_FLAVOR=main"
- --build-arg="AKMODS_FLAVOR=main"
- --build-arg="FEDORA_MAJOR_VERSION=39"
- --build-arg="TARGET_BASE=bluefin"
``` ```
This file acts as a template. It has all available settings outlined for you. Simple copy These files are a good starting point for your custom configuration. Simple copy those examples
it and modify it to your liking. For each project you want to handle with the forge you can you are interested in modify them to your liking.
create a dedicated file.
Details about the available variables are documented [here](./variables.md). Details about the available variables are documented [here](./variables.md).

View file

@ -10,16 +10,16 @@ The following configuration variables are available and can be set to your likin
<!-- markdownlint-disable MD013 --> <!-- markdownlint-disable MD013 -->
| Name | Type | Default value | Description | | Name | Type | Default value | Description |
| ---------------------------------- | ---- | ------------------------------------------------- | -------------------------------------------------------------------------------- | | ---------------------------------- | ---- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `forge_container_file` | str | Containerfile | Path to the Containerfile for Podman to build | | `forge_container_name` | str | Project name derived from `forge_git_repository_url` Example: `bluefin` | Container image name. |
| `forge_container_format` | str | oci | Format of the image Podman will build. Can be either `oci` or `docker` | | `forge_container_tag` | str | Evaluates to: `YYY-MM-DD_HHMMSS` Example: `2024-05-26_192206` | Container image tag. |
| `forge_git_repository_url` | str | <https://github.com/ublue-os/bluefin.git> | Git repository url | | `forge_container_file` | str | Containerfile | Path to the Containerfile for Podman to build |
| `forge_git_repository_destination` | str | `{{ forge_data_volume_mountpoint }}`/data/bluefin | Git destination where repository is cloned to. Can be any directory on your host | | `forge_container_format` | str | oci | Format of the image Podman will build. Can be either `oci` or `docker` |
| `forge_git_repository_version` | str | main | Git repository branch or tag or commit version | | `forge_container_extra_args` | list | [] | List of extra arguments which gets passed to the podman build process. Example: `[--build-arg="BASE_IMAGE_NAME=silverblue"]` |
| `forge_registry_url` | str | registry.ublue.local | Container registry url | | `forge_git_repository_url` | str | | Git repository url |
| `forge_git_repository_destination` | str | | Git destination where repository is cloned to. |
| `forge_git_repository_version` | str | main | Git repository branch or tag or commit version |
| `forge_registry_url` | str | registry.ublue.local | Container registry url |
<!-- markdownlint-enable MD013--> <!-- markdownlint-enable MD013-->
**_Note:_** The `{{ forge_data_volume_mountpoint }}` points to your ublue-os_forge-data
podman volume.

View file

@ -27,10 +27,6 @@ spec:
containers: containers:
- name: traefik.${FORGE_DOMAIN_NAME} - name: traefik.${FORGE_DOMAIN_NAME}
image: traefik # will be built on pod start image: traefik # will be built on pod start
resources:
limits:
memory: 128Mi
cpu: 200m
volumeMounts: volumeMounts:
- mountPath: /var/run/podman.sock - mountPath: /var/run/podman.sock
name: podman-socket name: podman-socket
@ -77,10 +73,6 @@ spec:
containers: containers:
- name: docker.${FORGE_DOMAIN_NAME} - name: docker.${FORGE_DOMAIN_NAME}
image: registry # will be built on pod start image: registry # will be built on pod start
resources:
limits:
memory: 512Mi
cpu: 200m
volumeMounts: volumeMounts:
- mountPath: /certs - mountPath: /certs
name: ublue-os_forge-certs-pvc name: ublue-os_forge-certs-pvc