QA & test update
This commit is contained in:
parent
c817784eab
commit
4f405a8709
@ -51,7 +51,10 @@ async def build(service=None, **kwargs):
|
|||||||
loop=loop,
|
loop=loop,
|
||||||
)
|
)
|
||||||
|
|
||||||
prefix = '' if os.getenv('BUILDAH_ISOLATION') == 'chroot' else 'buildah unshare '
|
if os.getenv('BUILDAH_ISOLATION') == 'chroot':
|
||||||
|
prefix = ''
|
||||||
|
else:
|
||||||
|
prefix = 'buildah unshare '
|
||||||
transport, protocol = await loop.subprocess_shell(
|
transport, protocol = await loop.subprocess_shell(
|
||||||
protocol_factory,
|
protocol_factory,
|
||||||
prefix + f'bash -eux {script}',
|
prefix + f'bash -eux {script}',
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class Packages:
|
|||||||
),
|
),
|
||||||
dnf=dict(
|
dnf=dict(
|
||||||
update='sudo dnf update',
|
update='sudo dnf update',
|
||||||
upgrade='sudo dnf upgrade --exclude container-selinux --best --assumeyes',
|
upgrade='sudo dnf upgrade --exclude container-selinux --best --assumeyes', # noqa
|
||||||
install='sudo dnf install --exclude container-selinux --setopt=install_weak_deps=False --best --assumeyes', # noqa
|
install='sudo dnf install --exclude container-selinux --setopt=install_weak_deps=False --best --assumeyes', # noqa
|
||||||
),
|
),
|
||||||
yum=dict(
|
yum=dict(
|
||||||
@ -22,7 +22,7 @@ class Packages:
|
|||||||
|
|
||||||
def __init__(self, *packages, **kwargs):
|
def __init__(self, *packages, **kwargs):
|
||||||
self.packages = list(packages)
|
self.packages = list(packages)
|
||||||
self.mgr = kwargs.pop('mgr')
|
self.mgr = kwargs.pop('mgr') if 'mgr' in kwargs else None
|
||||||
|
|
||||||
def pre_build(self, script):
|
def pre_build(self, script):
|
||||||
base = script.container.variable('base')
|
base = script.container.variable('base')
|
||||||
|
|||||||
@ -12,4 +12,6 @@ umounts() {
|
|||||||
}
|
}
|
||||||
trap umounts 0
|
trap umounts 0
|
||||||
ctr=$(buildah from $base)
|
ctr=$(buildah from $base)
|
||||||
mnt=$(buildah mount $ctr)
|
mnt=$(buildah mount $ctr)
|
||||||
|
echo "Copy.init_build"
|
||||||
|
echo "Copy.build"
|
||||||
@ -13,9 +13,12 @@ umounts() {
|
|||||||
trap umounts 0
|
trap umounts 0
|
||||||
ctr=$(buildah from $base)
|
ctr=$(buildah from $base)
|
||||||
mnt=$(buildah mount $ctr)
|
mnt=$(buildah mount $ctr)
|
||||||
|
echo "Packages.pre_build"
|
||||||
|
echo "Packages.build"
|
||||||
buildah run --user root $ctr -- mkdir -p /var/cache/apk
|
buildah run --user root $ctr -- mkdir -p /var/cache/apk
|
||||||
mkdir -p $(pwd)/.cache/apk
|
mkdir -p $(pwd)/.cache/apk
|
||||||
mount -o bind $(pwd)/.cache/apk $mnt/var/cache/apk
|
mount -o bind $(pwd)/.cache/apk $mnt/var/cache/apk
|
||||||
|
mounts=("$mnt/var/cache/apk" "${mounts[@]}")
|
||||||
buildah run $ctr -- ln -s /var/cache/apk /etc/apk/cache
|
buildah run $ctr -- ln -s /var/cache/apk /etc/apk/cache
|
||||||
old="$(find .cache/apk/ -name APKINDEX.* -mtime +3)"
|
old="$(find .cache/apk/ -name APKINDEX.* -mtime +3)"
|
||||||
if [ -n "$old" ] || ! ls .cache/apk/APKINDEX.*; then
|
if [ -n "$old" ] || ! ls .cache/apk/APKINDEX.*; then
|
||||||
|
|||||||
@ -13,9 +13,15 @@ umounts() {
|
|||||||
trap umounts 0
|
trap umounts 0
|
||||||
ctr=$(buildah from $base)
|
ctr=$(buildah from $base)
|
||||||
mnt=$(buildah mount $ctr)
|
mnt=$(buildah mount $ctr)
|
||||||
|
echo "User.init_build"
|
||||||
|
echo "User.init_build"
|
||||||
|
echo "Packages.pre_build"
|
||||||
|
echo "User.pre_build"
|
||||||
|
echo "Packages.build"
|
||||||
buildah run --user root $ctr -- mkdir -p /var/cache/apk
|
buildah run --user root $ctr -- mkdir -p /var/cache/apk
|
||||||
mkdir -p $(pwd)/.cache/apk
|
mkdir -p $(pwd)/.cache/apk
|
||||||
mount -o bind $(pwd)/.cache/apk $mnt/var/cache/apk
|
mount -o bind $(pwd)/.cache/apk $mnt/var/cache/apk
|
||||||
|
mounts=("$mnt/var/cache/apk" "${mounts[@]}")
|
||||||
buildah run $ctr -- ln -s /var/cache/apk /etc/apk/cache
|
buildah run $ctr -- ln -s /var/cache/apk /etc/apk/cache
|
||||||
old="$(find .cache/apk/ -name APKINDEX.* -mtime +3)"
|
old="$(find .cache/apk/ -name APKINDEX.* -mtime +3)"
|
||||||
if [ -n "$old" ] || ! ls .cache/apk/APKINDEX.*; then
|
if [ -n "$old" ] || ! ls .cache/apk/APKINDEX.*; then
|
||||||
@ -25,10 +31,12 @@ else
|
|||||||
fi
|
fi
|
||||||
buildah run --user root $ctr -- apk upgrade
|
buildah run --user root $ctr -- apk upgrade
|
||||||
buildah run --user root $ctr -- apk add shadow
|
buildah run --user root $ctr -- apk add shadow
|
||||||
|
echo "User.build"
|
||||||
if buildah run $ctr -- id 1000; then
|
if buildah run $ctr -- id 1000; then
|
||||||
i=$(buildah run $ctr -- id -n 1000)
|
i=$(buildah run $ctr -- id -n 1000)
|
||||||
buildah run $ctr -- usermod --home-dir /app --no-log-init 1000 $i
|
buildah run $ctr -- usermod --home-dir /app --no-log-init 1000 $i
|
||||||
else
|
else
|
||||||
buildah run $ctr -- useradd --home-dir /app --uid 1000 app
|
buildah run $ctr -- useradd --home-dir /app --uid 1000 app
|
||||||
fi
|
fi
|
||||||
|
echo "User.post_build"
|
||||||
buildah config --user app $ctr
|
buildah config --user app $ctr
|
||||||
Loading…
x
Reference in New Issue
Block a user