Git Product home page Git Product logo

vpsadminos-image-build-scripts's Introduction

vpsAdminOS Image Build Scripts

Deprecation notice

This repository has been merged into vpsAdminOS:

https://github.com/vpsfreecz/vpsadminos

Further development will take place there.

About

This is a collection of scripts used to build and test container images, which are then used by vpsAdminOS when creating new containers. Container image is a tarball with configuration and filesystems, see the specification. More information about container images can be found in the documentation.

Building images

Images can be built within vpsAdminOS using osctl-image. osctl-image needs the build scripts in its current working directory.

git clone [email protected]:vpsfreecz/vpsadminos-image-build-scripts.git
cd vpsadminos-image-build-scripts

Usage:

osctl-image --help
NAME
    osctl-image - Build, test and deploy vpsAdminOS images

SYNOPSIS
    osctl-image [global options] command [command options] [arguments...]

VERSION
    19.03.0

GLOBAL OPTIONS
    --help    - Show this message
    --version - Display the program version

COMMANDS
    build       - Build image
    ct          - Manage build and test containers
    deploy      - Build image, test it and deploy to repository
    help        - Shows a list of commands or help for one command
    instantiate - Build the image and use it in a container
    ls          - List available images
    test        - Test image

To get a list of available images, use:

osctl-image ls

osctl-image requires a dedicated ZFS dataset which is used for building images. The dataset should not have any data or subdatasets that you care about.

zfs create tank/image-builds

To build an image, use command osclt-image build, e.g.:

osctl-image build --build-dataset tank/image-builds alpine-3.9

Tests can be run as:

osctl-image test --build-dataset tank/image-builds alpine-3.9

Images can be also tested manually in container. Use command osctl-image instantiate to create one:

osctl-image instantiate --build-dataset tank/image-builds alpine-3.9

Managed containers can be listed using command osctl-image ct ls and cleaned up using osctl-image ct del. See man osctl-image(8) for more information.

Contributing build scripts

Target images are represented by directories in images/. Every image directory has to contain two files: config.sh and build.sh. config.sh is used to set variables such as distribution name, version and so on, see below. This information is used by osctl-image. build.sh is called to actually build the image.

Shared code can be placed into include/, follow the existing naming scheme.

How does it work

The image build script needs to prepare the distribution's root filesystem in directory stored in variable $INSTALL. The script can download arbitrary assets into directory $DOWNLOAD. When the script finishes, the $INSTALL directory should contain the root filesystem, i.e. directories like bin, usr, var, home and so on.

The build script can generate configuration script, that will be executed as chrooted within the $INSTALL directory. Function configure-append is used to append chunks of the configuration script and run-configure will chroot to the $INSTALL directory and run it. This is where you can use the distribution's package manager and other programs.

For example, to create a Debian image, you would use debootstrap to download the base root file system, then use the configuration script to install additional packages and configure the services.

Image name and variables

The image has to define the following variables in config.sh:

  • BUILDER - name of a builder that the image has to be built in, see below

Additional variables are optional:

  • DISTNAME, e.g. debian, ubuntu
  • RELVER, e.g. 9 for Debian or 16.04 for Ubuntu
  • ARCH (defaults to x86_64)
  • VENDOR (defaults to vpsadminos)
  • VARIANT (defaults to minimal)

If not set, osctl-image tries to extract the values from the image name, which should be in the following form:

<DISTNAME>[-RELVER[-ARCH[-VENDOR[-VARIANT]]]]

Builders

Images are built in builders, which are vpsAdminOS containers. Builders are defined in directory builders/ by two files: config.sh and setup.sh.

config.sh is similar to image configs, it specifies what distribution and version should the builder be created from. Builders are simply containers created from pre-existing images available in vpsAdminOS repository at https://images.vpsadminos.org, or whatever repository you have configured on your system.

setup.sh is run within the builder container after it is created. This script should installed whatever packages are needed to build images that use this builder.

vpsadminos-image-build-scripts's People

Contributors

aither64 avatar cooba13 avatar fbeke avatar jirimedved avatar jirutka avatar lopo avatar mmilata avatar oskar456 avatar pvanek avatar snajpa avatar sorki avatar spetr avatar werkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vpsadminos-image-build-scripts's Issues

sshd does not start on Fedora >=30

sshd sometimes does not start on boot on Fedora 30, even though it is enabled. It happens while testing built images and on staging as well. No idea what's going on, there's not even any attempt at starting it, the service is sometimes just ignored.

Ubuntu Locale

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_PAPER = "cs_CZ.UTF-8",
        LC_ADDRESS = "cs_CZ.UTF-8",
        LC_MONETARY = "cs_CZ.UTF-8",
        LC_NUMERIC = "cs_CZ.UTF-8",
        LC_TELEPHONE = "cs_CZ.UTF-8",
        LC_MESSAGES = "en_US.UTF-8",
        LC_IDENTIFICATION = "cs_CZ.UTF-8",
        LC_COLLATE = "en_US.UTF-8",
        LC_MEASUREMENT = "cs_CZ.UTF-8",
        LC_CTYPE = "en_US.UTF-8",
        LC_TIME = "cs_CZ.UTF-8",
        LC_NAME = "cs_CZ.UTF-8",
        LANG = "cs_CZ.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

I fix with this cmd

update-locale LC_ALL=en_US.UTF-8
update-locale LANGUAGE=en_US.UTF-8
update-locale LANG=en_US.UTF-8

CentOS 9 Stream

I installed fresh copy of template CentOS 9 Stream and when tried install any package I got error related to public key. In dnf.log I noticed: dnf.exceptions.Error: GPG check FAILED

021-12-06T16:01:25+0100 DEBUG Using rpmkeys executable at /usr/bin/rpmkeys to verify signatures
2021-12-06T16:01:25+0100 CRITICAL Importing GPG key 0x8483C65D:
Userid : "CentOS (CentOS Official Signing Key) [email protected]"
Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
2021-12-06T16:01:46+0100 INFO Key imported successfully
2021-12-06T16:01:46+0100 INFO Import of key(s) didn't help, wrong key(s)?
2021-12-06T16:01:46+0100 CRITICAL Public key for wget-1.21.1-7.el9.x86_64.rpm is not installed. Failing package is: wget-1.21.1-7.el9.x86_64

Override clamav-freshclam.service and set cpu quota

freshclam processes from multiple VPS tend to go crazy all at once, overloading the nodes. We can't really help it if people install it, but we could add override to all templates using systemd and limit the CPU usage, e.g.:

mkdir -p /etc/systemd/system/clamav-freshclam.service.d
cat <<EOF > /etc/systemd/system/clamav-freshclam.service.d/override.conf
[Service]
CPUQuota=25%
CPUWeight=10
EOF

Disable OOMScoreAdjust for dbus on Debian 8

dbus is not installed by default, but when installed, the VPS will not boot at all. It fails on:

Process: 237 ExecStart=/usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation (code=exited, status=206/OOM_ADJUST)

So we should add an override to the template and disable OOMScoreAdjust on dbus.service.

Debian 11 broken UTC timezone

UTC timezone is broken in Debian 11 image.

root@radio-h:~# zdump /usr/share/zoneinfo/UTC
/usr/share/zoneinfo/UTC  Thu Aug  4 14:17:18 2022 CEST

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.