diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 918f802..3de58c6 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -54,14 +54,12 @@ jobs: BASE=${{ matrix.base }} CRIU_VERSION=${{ matrix.criu }} - - name: Test - run: docker run --rm --privileged ${{ env.TAG_TEST }} criu check - - name: Test multi-stage build run: | cat <> ${{ matrix.nftables }}-multi-stage.Dockerfile FROM --platform=${{ env.PLATFORM }} ${{ matrix.base }} COPY --from=${{ env.TAG_TEST }} /criu/ / + RUN apk --update --no-cache add libnet libnl3 nftables protobuf-c EOF if [[ $? != 0 ]]; then @@ -73,7 +71,7 @@ jobs: -f ${{ matrix.nftables }}-multi-stage.Dockerfile \ . && \ - docker run --rm --privileged ${{ matrix.nftables }}-multi-stage:test criu check + docker run --rm --privileged ${{ matrix.nftables }}-multi-stage:test criu check --all -v4 - name: Login to Docker Hub if: github.event_name == 'push' diff --git a/README.md b/README.md index 37c000f..eae0ef1 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,7 @@ then: FROM --platform=amd64 alpine:3.18.5@sha256:d695c3de6fcd8cfe3a6222b0358425d40adfd129a8a47c3416faff1a8aece389 COPY --from=criu-with-nftables:criu-3.19-alpine-3.18.5 /criu/ / + +# Install deps +RUN apk --update --no-cache add libnet libnl3 nftables protobuf-c ``` diff --git a/multi-stage-setup.py b/multi-stage-setup.py deleted file mode 100644 index d30e074..0000000 --- a/multi-stage-setup.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 - -from pathlib import Path -from shutil import copy2 -from subprocess import run -from sys import exit - -CRIU_ROOT = '/criu' -CRIU_BIN_DIR = f'{CRIU_ROOT}/usr/bin' - - -def setup_criu_root(): - Path(CRIU_ROOT).mkdir(parents=True, exist_ok=False) - Path(CRIU_BIN_DIR).mkdir(parents=True, exist_ok=False) - - if not run(f'cp `which criu` {CRIU_BIN_DIR}', shell=True).returncode == 0: - exit(1) - - -def copy_dep(dep): - dep_dir = str(Path(CRIU_ROOT).joinpath(Path(dep).parent.relative_to('/'))) - Path(dep_dir).mkdir(parents=True, exist_ok=True) - - copy2(dep, dep_dir) - - -if __name__ == '__main__': - setup_criu_root() - - res = run('ldd `which criu`', capture_output=True, shell=True) - if not res.returncode == 0: - exit(1) - - deps = res.stdout.decode().strip().split("\n") - - for dep in deps: - parts = dep.strip().split(' => ') - if len(parts) not in (1, 2): - exit(1) - - part1 = None - part2 = None - - if len(parts) == 1: - part1 = parts[0].split(' (0x')[0] - part2 = part1 - else: - part2 = parts[1].split(' (0x')[0] - part1 = str(Path(part2).parent.joinpath(parts[0])) - - if not part1 or not part2: - exit(1) - - copy_dep(part1) - - if part1 != part2: - copy_dep(part2) diff --git a/with-nftables.Dockerfile b/with-nftables.Dockerfile index e4385fa..4bdd579 100644 --- a/with-nftables.Dockerfile +++ b/with-nftables.Dockerfile @@ -6,13 +6,13 @@ FROM --platform=$PLATFORM $BASE ARG CRIU_VERSION RUN apk --update --no-cache add \ + asciidoc \ bash \ build-base \ coreutils \ procps \ gcc \ git \ - gnutls-dev \ libaio-dev \ libcap-dev \ libnet-dev \ @@ -24,19 +24,18 @@ RUN apk --update --no-cache add \ protobuf-dev \ py3-pip \ py3-protobuf \ + py3-yaml \ python3 \ libcap-utils \ libdrm-dev \ - util-linux - -WORKDIR /tmp + util-linux \ + xmlto RUN wget "http://github.com/checkpoint-restore/criu/archive/v${CRIU_VERSION}/criu-${CRIU_VERSION}.tar.gz" && \ tar -xzf "criu-${CRIU_VERSION}.tar.gz" && \ cd "criu-${CRIU_VERSION}" && \ - make -j $(nproc) install-criu - -COPY multi-stage-setup.py multi-stage-setup.py - -RUN chmod +x multi-stage-setup.py && \ - ./multi-stage-setup.py + make -j $(nproc) CONFIG_AMDGPU=n PREFIX=/usr DESTDIR=/criu LIBDIR=/usr/lib LD=gcc install && \ + rm -f /criu/usr/lib/*.a && \ + rm -rf /criu/usr/lib/python3* && \ + rm -rf /criu/usr/libexec/compel/*.a && \ + rm -f /criu/usr/libexec/criu/scripts/systemd-autofs-restart.sh diff --git a/without-nftables.Dockerfile b/without-nftables.Dockerfile index 4f5996b..3922087 100644 --- a/without-nftables.Dockerfile +++ b/without-nftables.Dockerfile @@ -6,13 +6,13 @@ FROM --platform=$PLATFORM $BASE ARG CRIU_VERSION RUN apk --update --no-cache add \ + asciidoc \ bash \ build-base \ coreutils \ procps \ gcc \ git \ - gnutls-dev \ libaio-dev \ libcap-dev \ libnet-dev \ @@ -22,19 +22,18 @@ RUN apk --update --no-cache add \ protobuf-dev \ py3-pip \ py3-protobuf \ + py3-yaml \ python3 \ libcap-utils \ libdrm-dev \ - util-linux - -WORKDIR /tmp + util-linux \ + xmlto RUN wget "http://github.com/checkpoint-restore/criu/archive/v${CRIU_VERSION}/criu-${CRIU_VERSION}.tar.gz" && \ tar -xzf "criu-${CRIU_VERSION}.tar.gz" && \ cd "criu-${CRIU_VERSION}" && \ - make -j $(nproc) install-criu - -COPY multi-stage-setup.py multi-stage-setup.py - -RUN chmod +x multi-stage-setup.py && \ - ./multi-stage-setup.py + make -j $(nproc) CONFIG_AMDGPU=n PREFIX=/usr DESTDIR=/criu LIBDIR=/usr/lib LD=gcc install && \ + rm -f /criu/usr/lib/*.a && \ + rm -rf /criu/usr/lib/python3* && \ + rm -rf /criu/usr/libexec/compel/*.a && \ + rm -f /criu/usr/libexec/criu/scripts/systemd-autofs-restart.sh