Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Docker Image CI
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: ["self-hosted", "images"]
container:
image: gcr.io/kaniko-project/executor:debug
permissions:
contents: read
packages: write
steps:
- name: Configure Docker Authentication
run: |
mkdir -p /kaniko/.docker
echo '{"auths":{"ghcr.io":{"auth":"'"$(echo -n $GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }} | base64)"'"}}}' > /kaniko/.docker/config.json

- name: Build and Push Docker Image
env:
IMAGE_NAME: docker-image-builder
GIT_USERNAME: "kaniko-bot"
GIT_PASSWORD: "${{ secrets.GITHUB_TOKEN }}"
run: |
/kaniko/executor \
--context="${{ github.repositoryUrl }}#${{ github.ref }}#${{ github.sha }}" \
--dockerfile ./Dockerfile \
--destination=ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}:${{ github.sha }} \
$(if [ "${GITHUB_REF_NAME}" = "master" ]; then echo "--destination ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}:latest"; fi)
36 changes: 5 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:22.04
FROM ubuntu:24.04

# Prerequisities
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y tzdata --no-install-recommends && apt-get install -y --no-install-recommends \
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
lsb-release \
openssh-client \
Expand All @@ -11,23 +11,12 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y tzdata -
jq \
wget \
software-properties-common \
xvfb \
git \
libarchive-tools \
rsync

# QEMU
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends qemu-kvm ebtables libguestfs-tools

# Virtualbox
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y linux-headers-generic virtualbox

RUN VIRTUALBOX_VERSION=`VBoxManage --version | sed -r -e '/[0-9]+\.[0-9]+\.[0-9]+/!d' -e 's/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/'` && \
wget -q https://download.virtualbox.org/virtualbox/${VIRTUALBOX_VERSION}/Oracle_VM_VirtualBox_Extension_Pack-${VIRTUALBOX_VERSION}.vbox-extpack && \
echo "y" | VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-${VIRTUALBOX_VERSION}.vbox-extpack && \
rm Oracle_VM_VirtualBox_Extension_Pack-${VIRTUALBOX_VERSION}.vbox-extpack && \
VBoxManage setproperty vrdeextpack "Oracle VM VirtualBox Extension Pack"

# Packer
RUN PACKER_VERSION=$(wget -O- https://releases.hashicorp.com/packer/ 2> /dev/null \
| sed -r -e 's/.*packer_([0-9]+\.[0-9]+\.[0-9]+)<\/a>.*/\1/' -e '/^[0-9]+\.[0-9]+\.[0-9]+$/!d' \
Expand All @@ -39,31 +28,16 @@ RUN PACKER_VERSION=$(wget -O- https://releases.hashicorp.com/packer/ 2> /dev/nul
mv packer /usr/local/bin && \
rm packer.zip

# Vagrant
RUN VAGRANT_VERSION=$(wget -O- https://releases.hashicorp.com/vagrant/ 2> /dev/null \
| sed -r -e 's/.*vagrant_([0-9]+\.[0-9]+\.[0-9]+)<\/a>.*/\1/' -e '/^[0-9]+\.[0-9]+\.[0-9]+$/!d' \
| sort --version-sort --reverse \
| head -n 1) && \
wget -q -O vagrant.zip https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_linux_amd64.zip && \
unzip vagrant.zip && \
chmod +x vagrant && \
mv vagrant /usr/local/bin && \
rm vagrant.zip

# Openstack-cli
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-openstackclient s3cmd zip

# Ansible
#RUN apt-add-repository --yes --update ppa:ansible/ansible
#RUN apt-get install -y ansible
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip && pip3 install ansible pywinrm
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip && pip3 install ansible pywinrm --break-system-packages

# GitLab-Tofu
# Tofu
RUN curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh && \
chmod +x install-opentofu.sh && \
./install-opentofu.sh --install-method standalone && \
rm ./install-opentofu.sh && \
curl --proto '=https' --tlsv1.2 -fsSL https://gitlab.com/components/opentofu/-/raw/main/src/gitlab-tofu.sh -o /usr/bin/gitlab-tofu && \
chmod 755 /usr/bin/gitlab-tofu
rm ./install-opentofu.sh

RUN apt-get -y clean
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Docker Image Builder

This repository contains definition of a Docker image with QEMU, VBox, Packer, Vagrant, OpenStack-cli and Ansible, which is used in [ci-cd-virtual-images](https://gitlab.ics.muni.cz/muni-kypo-images/ci-cd-virtual-images).

The Docker image is also available on [Docker Hub](https://hub.docker.com/repository/docker/munikypo/packer-vbox-qemu).
This repository contains definition of a Docker image with QEMU, Packer, Ansible and OpenTofu.

## Example usage
```bash
Expand All @@ -14,5 +12,4 @@ sudo docker run --rm -it --privileged --network=host -w /opt -v `pwd`:/opt packe
```

## License

This project is licensed under the [MIT License](LICENSE).