-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9050a66
Showing
7 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
name: Build and Push Toolbox Image | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'Containerfile' | ||
- 'files/**' | ||
schedule: | ||
- cron: "22 22 * * */7" | ||
|
||
env: | ||
IMAGE_REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
attestations: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: redhat-actions/podman-login@v1 | ||
with: | ||
registry: ${{ env.IMAGE_REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get Image version | ||
id: get-image-version | ||
run: | | ||
VERSION=$(date +'%y.%U') | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Build and Push Toolbox image | ||
id: build-image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
image: ${{ env.IMAGE_NAME }} | ||
containerfiles: | | ||
./Containerfile | ||
tags: latest ${{ env.VERSION }} | ||
build-args: | | ||
VERSION=${{ env.VERSION }} | ||
extra-args: | | ||
--squash | ||
- name: Push to Github Container Registry | ||
id: push-to-registry | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
image: ${{ steps.build-image.outputs.image }} | ||
registry: ${{ env.IMAGE_REGISTRY }} | ||
tags: ${{ steps.build-image.outputs.tags }} | ||
|
||
- name: Generate artifact attestation | ||
uses: actions/attest-build-provenance@v1 | ||
with: | ||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | ||
subject-digest: ${{ steps.push.outputs.digest }} | ||
push-to-registry: true | ||
continue-on-error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
FROM registry.fedoraproject.org/fedora:41 | ||
|
||
# Set build-time arguments with default values | ||
ARG NAME=dev-toolbox | ||
ARG VENDOR="elromanos" | ||
ARG VERSION=41 | ||
|
||
# Set environment variables, falling back to ARGs for default values | ||
ENV NAME=${NAME} \ | ||
VENDOR=${VENDOR} \ | ||
VERSION=${VERSION} | ||
|
||
LABEL com.github.containers.toolbox="true" \ | ||
org.opencontainers.image.name="$NAME" \ | ||
org.opencontainers.image.description="My custom Toolbox image." \ | ||
org.opencontainers.image.source="https://github.com/elromanos/dev-toolbox" \ | ||
org.opencontainers.image.version="$VERSION" \ | ||
org.opencontainers.image.vendor="$VENDOR" \ | ||
org.opencontainers.image.documentation="https://github.com/elromanos/dev-toolbox/blob/main/README.md" \ | ||
summary="Image for creating my dev toolbx, from a Fedora container." \ | ||
vendor="$VENDOR" \ | ||
name="$NAME" \ | ||
version="$VERSION" | ||
|
||
# Copy required files | ||
COPY files/dnf.conf /etc/dnf/dnf.conf | ||
|
||
# Setup the VS Code YUM repository | ||
RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc | ||
COPY files/vscode.repo /etc/yum.repos.d/ | ||
|
||
# Install required packages | ||
# | ||
# bind-utils - for basic DNS troubleshooting | ||
# code - VS Code | ||
# diffutils - diff tools | ||
# direnv - for managing dev environment variables | ||
# helix - modern text editor | ||
# make - for running make tasks | ||
# man-db - access to man pages | ||
# pass - managing passwords | ||
# pinentry - passing passphrases to GPG | ||
# poetry - managing Python projects | ||
# pre-commit - running pre-commit tasks | ||
# pwgen - generating passwords | ||
# python3-lsp-server - python LSP implementation for helix | ||
# rcm - managing dotfiles | ||
# tmux - managing screen sessions | ||
# | ||
RUN dnf install -y bind-utils code diffutils direnv helix make man-db pass pinentry poetry pre-commit pwgen \ | ||
python3-lsp-server rcm tmux && \ | ||
dnf clean all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Ilias Romanos | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# My Dev Toolbox | ||
|
||
> This image is meant to be used with the toolbox-create(1) command. | ||
Since I started using [Fedora Silverblue] I've switched my workflow to use toolbox to set up my dev environments, | ||
instead of overlaying packages, trying to keep my deployments as clean as possible. | ||
|
||
As I was learing my ways around it, I kept having to re-create my toolboxes and had to run multiple commands everytime | ||
to set them up as I wanted it to. | ||
|
||
Eventually, I wrote a bash script, which worked fine. | ||
|
||
But recently I came across the **Custom Images** section of the [Toolbx Documentation], where it describes how one can | ||
go on to create their own custom Toolbx image and use that. | ||
|
||
This repo is set up to track my Containerfile of my custom image for dev work, as well as notes and scripts related to | ||
it. | ||
|
||
The relevant GitHub Actions were set up in order to build a new image everytime there are changes either in the | ||
Containerfile or the files in the `files` directory. | ||
|
||
## Versioning | ||
|
||
The latest version of image _should_ always be available as `ghcr.io/elromanos/dev-toolbox:latest`. | ||
|
||
A cron job is defined to run and update it once a week, with the latest Fedora repo updates. The tag for such images is | ||
set as **YY.WW** where **YY** is the last two digits of the year and **WW** the week number it was build. So, **24.45** | ||
is the image build on the 45th week of 2024. | ||
|
||
## Setup | ||
|
||
In order for the custom image to be loaded by default when I create a new toolbox, I need to override toolbox's default | ||
settings. To do so, I had to create the `~/.config/containers/toolbox.conf` file with the following TOML content: | ||
|
||
```toml | ||
[general] | ||
image = "ghcr.io/elromanos/dev-toolbox:latest" | ||
``` | ||
|
||
## F.A.Q. | ||
|
||
- **Q: Why Podman and not Docker?** [Fedora Silverblue] comes with Podman pre-installed. As I want to keep my base | ||
image as close to the defaults as possible, I decided to keep using Podman. For the simple needs of this exercise, | ||
Docker and Podman _should_ be interchangable/compatible. | ||
|
||
[Fedora Silverblue]: https://fedoraproject.org/atomic-desktops/silverblue/ | ||
[Toolbx Documentation]: https://containertoolbx.org/doc/ | ||
[Red Hat Actions]: https://github.com/redhat-actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# see `man dnf.conf` for defaults and possible options | ||
|
||
[main] | ||
tsflags=nodocs | ||
install_weak_deps=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[vscode] | ||
name=Visual Studio Code | ||
baseurl=https://packages.microsoft.com/yumrepos/vscode | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://packages.microsoft.com/keys/microsoft.asc |