1
0
out-of-tree/tools/qemu-ubuntu-img/Dockerfile

37 lines
1.1 KiB
Docker
Raw Normal View History

# Copyright 2018 Mikhail Klementev. All rights reserved.
# Use of this source code is governed by a AGPLv3 license
# (or later) that can be found in the LICENSE file.
#
# Usage:
#
2023-01-19 17:22:25 +00:00
# $ docker build -t gen-ubuntu2204-image .
# $ docker run --privileged -v $(pwd):/shared -t gen-ubuntu2204-image
#
2023-01-19 17:22:25 +00:00
# ubuntu2204.img will be created in current directory. You can change $(pwd) to
# different directory to use different destination for image.
#
2023-01-19 17:22:25 +00:00
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install -y debootstrap qemu-utils
RUN apt install -y linux-image-generic
ENV TMPDIR=/tmp/ubuntu
ENV IMAGEDIR=/tmp/image
2023-01-19 17:22:25 +00:00
ENV IMAGE=/shared/ubuntu2204.img
ENV REPOSITORY=http://archive.ubuntu.com/ubuntu
2023-01-19 17:22:25 +00:00
ENV RELEASE=jammy
RUN mkdir $IMAGEDIR
2019-08-21 06:16:25 +00:00
# Must be executed with --privileged because of /dev/loop
2019-08-31 12:45:55 +00:00
CMD debootstrap --include=openssh-server,policykit-1 \
$RELEASE $TMPDIR $REPOSITORY && \
/shared/setup.sh $TMPDIR && \
qemu-img create $IMAGE 2G && \
mkfs.ext4 -F $IMAGE && \
mount -o loop $IMAGE $IMAGEDIR && \
cp -a $TMPDIR/* $IMAGEDIR/ && \
umount $IMAGEDIR