mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 19:16:23 +00:00
rootfs: add alpine rootfs support
Fixes: #52 Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
parent
de6e4dc93f
commit
c8403836c0
3
rootfs-builder/alpine/Dockerfile.in
Normal file
3
rootfs-builder/alpine/Dockerfile.in
Normal file
@ -0,0 +1,3 @@
|
||||
From golang:@GO_VERSION@-alpine3.7
|
||||
|
||||
RUN apk update && apk add git make bash gcc musl-dev linux-headers apk-tools-static
|
23
rootfs-builder/alpine/config.sh
Normal file
23
rootfs-builder/alpine/config.sh
Normal file
@ -0,0 +1,23 @@
|
||||
# This is a configuration file add extra variables to
|
||||
# be used by build_rootfs() from rootfs_lib.sh the variables will be
|
||||
# loaded just before call the function.
|
||||
|
||||
# Here there are a couple of variables you may need.
|
||||
# Remove them or add more
|
||||
|
||||
# alpine version
|
||||
OS_VERSION=${OS_VERSION:-v3.7}
|
||||
|
||||
# Essential base packages
|
||||
BASE_PACKAGES="alpine-base"
|
||||
|
||||
# Alpine mirror to use
|
||||
# See a list of mirrors at http://nl.alpinelinux.org/alpine/MIRRORS.txt
|
||||
MIRROR=http://dl-5.alpinelinux.org/alpine
|
||||
|
||||
# Default Architecture
|
||||
ARCH=${ARCH:-x86_64}
|
||||
|
||||
# Mandatory Packages that must be installed
|
||||
# - iptables: Need by Kata agent
|
||||
PACKAGES="iptables"
|
52
rootfs-builder/alpine/rootfs_lib.sh
Normal file
52
rootfs-builder/alpine/rootfs_lib.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2018 HyperHQ Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
check_root()
|
||||
{
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "Root is needed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# - Arguments
|
||||
# rootfs_dir=$1
|
||||
#
|
||||
# - Optional environment variables
|
||||
#
|
||||
# EXTRA_PKGS: Variable to add extra PKGS provided by the user
|
||||
#
|
||||
# BIN_AGENT: Name of the Kata-Agent binary
|
||||
#
|
||||
# Any other configuration variable for a specific distro must be added
|
||||
# and documented on its own config.sh
|
||||
#
|
||||
# - Expected result
|
||||
#
|
||||
# rootfs_dir populated with rootfs pkgs
|
||||
# It must provide a binary in /sbin/init
|
||||
build_rootfs() {
|
||||
# Mandatory
|
||||
local ROOTFS_DIR=$1
|
||||
|
||||
# In case of support EXTRA packages, use it to allow
|
||||
# users add more packages to the base rootfs
|
||||
local EXTRA_PKGS=${EXTRA_PKGS:-}
|
||||
|
||||
# Populate ROOTFS_DIR
|
||||
check_root
|
||||
mkdir -p "${ROOTFS_DIR}"
|
||||
|
||||
/sbin/apk.static \
|
||||
-X ${MIRROR}/${OS_VERSION}/main \
|
||||
-U \
|
||||
--allow-untrusted \
|
||||
--root ${ROOTFS_DIR}\
|
||||
--initdb add ${BASE_PACKAGES} ${EXTRA_PKGS} ${PACKAGES}
|
||||
|
||||
mkdir -p ${ROOTFS_DIR}{/root,/etc/apk,/proc}
|
||||
echo "${MIRROR}/${OS_VERSION}/main" > ${ROOTFS_DIR}/etc/apk/repositories
|
||||
}
|
@ -104,6 +104,7 @@ ENV PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin
|
||||
pushd ${dir}
|
||||
[ -f "${dockerfile_template}" ] || die "${dockerfile_template}: file not found"
|
||||
sed \
|
||||
-e "s|@GO_VERSION@|${GO_VERSION}|g" \
|
||||
-e "s|@OS_VERSION@|${OS_VERSION}|g" \
|
||||
-e "s|@INSTALL_GO@|${install_go//$'\n'/\\n}|g" \
|
||||
${dockerfile_template} > Dockerfile
|
||||
@ -209,6 +210,7 @@ OK "Pull Agent source code"
|
||||
|
||||
info "Build agent"
|
||||
pushd "${GOPATH}/src/${GO_AGENT_PKG}"
|
||||
make clean
|
||||
make INIT=${AGENT_INIT}
|
||||
make install DESTDIR="${ROOTFS_DIR}" INIT=${AGENT_INIT}
|
||||
popd
|
||||
|
Loading…
Reference in New Issue
Block a user