From 16a31a122584ba33e612c23e8e63f7e50aced1c7 Mon Sep 17 00:00:00 2001 From: yangniao23 Date: Sun, 27 Sep 2020 23:38:17 +0900 Subject: [PATCH] =?utf8?q?Add=20Docker=E3=81=A7=E3=81=AE=E6=9B=B8=E3=81=8D?= =?utf8?q?=E5=87=BA=E3=81=97=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Dockerfile | 7 +++++-- docker-build.sh | 46 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e2ac8b3..40c3b63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ FROM fedora:32 RUN echo 'nameserver 1.1.1.1' > /etc/resolv.conf +RUN echo 'keepcache = 1' >> /etc/dnf/dnf.conf RUN dnf update -y -RUN dnf install -y squashfs-tools grub2 e2fsprogs +RUN dnf install -y squashfs-tools grub2 grub2-tools-extra e2fsprogs grub2-efi-ia32-modules grub2-efi-x64-modules dosfstools xorriso +RUN dnf makecache COPY . /lfbs WORKDIR /lfbs #RUN git checkout dev -CMD ["./lfbs", "releng"] +ENTRYPOINT ["./lfbs"] +CMD [] diff --git a/docker-build.sh b/docker-build.sh index 9a98677..71032c3 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -11,7 +11,47 @@ if ! type docker >/dev/null 2>&1; then exit 1 fi +_usage () { + echo "usage ${0} [options]" + echo + echo " General options:" + echo " -o | --build-opiton \"[options]\" send the build option to ./lfbs" + echo " -c | --clean Enable --no-cache option when build docker image" + echo " -h | --help This help message and exit" + echo +} + +# Start parse options +ARGUMENT="${@}" +while (( $# > 0 )); do + case ${1} in + -o | --build-opiton) + BUILD_OPT="${2}" + shift 2 + ;; + -c | --clean) + NO_CACHE="--no-cache" # Enable --no-cache option + shift 1 + ;; + -h | --help) + _usage + exit 0 + ;; + --) + shift + break + ;; + *) + msg_error "Invalid argument '${1}'" + _usage 1 + ;; + esac +done + + +# End parse options + SCRIPT_DIR=$(cd $(dirname $0); pwd) -cd $SCRIPT_DIR -docker build -t lfbs-build:latest . -docker run -e _DOCKER=true -t -i --privileged -v $SCRIPT_DIR/out:/lfbs/out -v /usr/lib/modules:/usr/lib/modules:ro lfbs-build +cd ${SCRIPT_DIR} +docker build ${NO_CACHE} -t lfbs-build:latest . +docker run -t -i --privileged -v ${SCRIPT_DIR}/out:/lfbs/out -v /usr/lib/modules:/usr/lib/modules:ro -v ${SCRIPT_DIR}/cache:/lfbs/cache lfbs-build "${BUILD_OPT}" -- 2.11.0