Skip to content

Instantly share code, notes, and snippets.

@zonggen
Last active April 15, 2020 19:09
Show Gist options
  • Save zonggen/0050a3d99e0ed4c378333f65adf2ea04 to your computer and use it in GitHub Desktop.
Save zonggen/0050a3d99e0ed4c378333f65adf2ea04 to your computer and use it in GitHub Desktop.
Quick start on CoreOS Assembler and Fedora CoreOS
#!/usr/bin/env bash
# this script will use podman, but docker will work too
rpm -qa | grep -q podman || (echo "podman not installed!" ; exit 1)
# checks if cosa image was pulled previously
podman image exists quay.io/coreos-assembler/coreos-assembler || \
podman pull quay.io/coreos-assembler/coreos-assembler
# create a tmp directory for storing builds
mkdir -p fcos && cd fcos
# define the _real_ cosa command
# https://github.com/coreos/coreos-assembler#define-a-bash-alias-to-run-cosa
cosa() {
env | grep COREOS_ASSEMBLER
set -x
podman run --rm -ti --security-opt label=disable --privileged \
--uidmap=1000:0:1 --uidmap=0:1:1000 --uidmap 1001:1001:64536 \
-v ${PWD}:/srv/ --device /dev/kvm --device /dev/fuse \
--tmpfs /tmp -v /var/tmp:/var/tmp --name cosa \
${COREOS_ASSEMBLER_CONFIG_GIT:+-v $COREOS_ASSEMBLER_CONFIG_GIT:/srv/src/config/:ro} \
${COREOS_ASSEMBLER_GIT:+-v $COREOS_ASSEMBLER_GIT/src/:/usr/lib/coreos-assembler/:ro} \
${COREOS_ASSEMBLER_CONTAINER_RUNTIME_ARGS} \
${COREOS_ASSEMBLER_CONTAINER:-quay.io/coreos-assembler/coreos-assembler:latest} "$@"
rc=$?; set +x; return $rc
}
# run the cosa container and run shell
cosa shell
@zonggen
Copy link
Author

zonggen commented Apr 15, 2020

Instruction for building a FCOS image:

# download the script from gist
# enter the cosa container shell
chmod +x ./cosa && ./cosa

# inside the cosa container
# fetch the Fedora CoreOS configuration
cosa init https://github.com/coreos/fedora-coreos-config

# fetch metadata and packages
cosa fetch

# build the image (qemu on default)
cosa build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment