Skip to content

Commit

Permalink
Merge pull request #4355 from werf/feat-image
Browse files Browse the repository at this point in the history
feat(buildah): build qemu image for mac
  • Loading branch information
ilya-lesikov committed Apr 8, 2022
2 parents ed61eb6 + a024274 commit aa1375e
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -34,3 +34,5 @@
/.github/trdl/lib
main
buildah-test

/scripts/images/image
6 changes: 5 additions & 1 deletion Makefile
@@ -1,4 +1,4 @@
.PHONY: all werf buildah-test fmt lint docs clean
.PHONY: all werf buildah-test fmt lint docs clean build-images

all: werf

Expand Down Expand Up @@ -36,6 +36,10 @@ docs:
./docs/regen.sh


build-images:
cd ./scripts/images && PACKER_LOG=1 packer build -force template.pkr.hcl


clean:
rm -f $$GOPATH/bin/werf
rm -f $$GOPATH/buildah-test
Empty file.
26 changes: 26 additions & 0 deletions scripts/images/cloud-data/user-data
@@ -0,0 +1,26 @@
#cloud-config
fqdn: werf
hostname: werf
timezone: UTC
locale: en_US
disable_root: false
ssh_pwauth: true

ntp:
enabled: true

system_info:
default_user:
name: werf
lock_passwd: false
plain_text_passwd: werf
shell: /bin/bash
groups:
- sudo
sudo: "ALL=(ALL) NOPASSWD:ALL"

users:
- default

chpasswd:
expire: false
53 changes: 53 additions & 0 deletions scripts/images/template.pkr.hcl
@@ -0,0 +1,53 @@
source "qemu" "werf-ubuntu-amd64-20-04" {
disk_image = true
floppy_files = ["cloud-data/user-data", "cloud-data/meta-data"]
floppy_label = "cidata"
skip_resize_disk = true
format = "qcow2"
iso_checksum = "sha256:c33e4d8f8fd52d639aa114b237274da428be7fd95025e20787b11cf77507d111"
iso_target_extension = "qcow2"
iso_url = "https://cloud-images.ubuntu.com/releases/focal/release-20220322/ubuntu-20.04-server-cloudimg-amd64.img"
memory = "2048"
output_directory = "image"
qemuargs = [
["-smp", "2"],
]
headless = true
use_default_display = true
ssh_password = "werf"
ssh_port = 22
ssh_username = "werf"
ssh_timeout = "10m"
ssh_handshake_attempts = 150
vm_name = "werf-ubuntu-amd64-20.04.qcow2"
}

build {
sources = ["source.qemu.werf-ubuntu-amd64-20-04"]

provisioner "shell" {
inline = ["/usr/bin/cloud-init status --wait"]
timeout = "10m"
}

provisioner "shell" {
env = {
"DEBIAN_FRONTEND": "noninteractive"
}
inline = [
"echo 'user.max_user_namespaces = 15000' | sudo tee -a /etc/sysctl.conf",
"echo 'kernel.unprivileged_userns_clone = 1' | sudo tee -a /etc/sysctl.conf",
"sudo apt-get update -yq",
"sudo apt-get upgrade -yq",
"sudo apt-get install -yq linux-image-virtual-hwe-20.04 crun uidmap",
"mkdir -p ~/.local/share/containers",
"sudo apt-get -yq autoremove --purge snapd",
"sudo apt-get -yq purge vim git linux-headers-* rsync strace",
"sudo apt-get autoremove -yq",
"sudo rm -rf /var/cache/snapd/ /snap /var/cache/apt /var/lib/apt/lists ~/snap",
"sync",
"sudo dd if=/dev/zero of=/zeroing || true; sync && sudo rm -rf /zeroing",
"sync",
]
}
}

0 comments on commit aa1375e

Please sign in to comment.