From fc56c53d04d7e499a91d0526842a6072477ddb96 Mon Sep 17 00:00:00 2001 From: Ryo Nakamura Date: Sat, 5 Nov 2022 21:26:34 +0900 Subject: add install-build-deps.sh and fix docker build procedure --- docker/.gitignore | 2 -- docker/Dockerfile-centos-8 | 22 ++++++++++++++-------- docker/Dockerfile-ubuntu-20.04 | 18 ++++++++++++------ docker/Dockerfile-ubuntu-22.04 | 18 ++++++++++++------ docker/README.md | 8 +++++--- 5 files changed, 43 insertions(+), 25 deletions(-) delete mode 100644 docker/.gitignore (limited to 'docker') diff --git a/docker/.gitignore b/docker/.gitignore deleted file mode 100644 index 7fcc085..0000000 --- a/docker/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.deb -*.rpm diff --git a/docker/Dockerfile-centos-8 b/docker/Dockerfile-centos-8 index 7c80119..8deae76 100644 --- a/docker/Dockerfile-centos-8 +++ b/docker/Dockerfile-centos-8 @@ -1,7 +1,8 @@ FROM centos:8 -ARG DEBIAN_FRONTEND=noninteractive -ARG workdir="/" +ARG mscpdir="/mscp" + +COPY . ${mscpdir} # from https://stackoverflow.com/questions/70963985/error-failed-to-download-metadata-for-repo-appstream-cannot-prepare-internal RUN cd /etc/yum.repos.d/ @@ -9,10 +10,15 @@ RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* RUN set -ex && yum -y update && yum -y install \ - git cmake gcc make libssh-devel rpm-build + rpm-build + +RUN ${mscpdir}/install-build-deps.sh + +RUN cd ${mscpdir} \ + && rm -rf build + +RUN cd ${mscpdir} \ + && cmake -B build -DBUILD_PKG=1 \ + && cd ${mscpdir}/build \ + &&cpack -G RPM CPackConfig.cmake -RUN cd ${workdir} \ - && git clone --depth=1 https://github.com/upa/mscp \ - && mkdir mscp/build && cd mscp/build \ - && cmake .. -DBUILD_PKG=1 \ - && cpack -G RPM CPackConfig.cmake diff --git a/docker/Dockerfile-ubuntu-20.04 b/docker/Dockerfile-ubuntu-20.04 index d48d4f1..687072c 100644 --- a/docker/Dockerfile-ubuntu-20.04 +++ b/docker/Dockerfile-ubuntu-20.04 @@ -1,13 +1,19 @@ FROM ubuntu:20.04 ARG DEBIAN_FRONTEND=noninteractive -ARG workdir="/" +ARG mscpdir="/mscp" + +COPY . ${mscpdir} RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \ - git cmake build-essential libssh-dev ca-certificates + ca-certificates + +RUN ${mscpdir}/install-build-deps.sh + +RUN cd ${mscpdir} \ + && rm -rf build -RUN cd ${workdir} \ - && git clone --depth=1 https://github.com/upa/mscp \ - && mkdir mscp/build && cd mscp/build \ - && cmake .. -DBUILD_PKG=1 \ +RUN cd ${mscpdir} \ + && cmake -B build -DBUILD_PKG=1 \ + && cd ${mscpdir}/build \ && cpack -G DEB CPackConfig.cmake diff --git a/docker/Dockerfile-ubuntu-22.04 b/docker/Dockerfile-ubuntu-22.04 index eb89243..59a57d2 100644 --- a/docker/Dockerfile-ubuntu-22.04 +++ b/docker/Dockerfile-ubuntu-22.04 @@ -1,13 +1,19 @@ FROM ubuntu:22.04 ARG DEBIAN_FRONTEND=noninteractive -ARG workdir="/" +ARG mscpdir="/mscp" + +COPY . ${mscpdir} RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \ - git cmake build-essential libssh-dev ca-certificates + ca-certificates + +RUN ${mscpdir}/install-build-deps.sh + +RUN cd ${mscpdir} \ + && rm -rf build -RUN cd ${workdir} \ - && git clone --depth=1 https://github.com/upa/mscp \ - && mkdir mscp/build && cd mscp/build \ - && cmake .. -DBUILD_PKG=1 \ +RUN cd ${mscpdir} \ + && cmake -B build -DBUILD_PKG=1 \ + && cd ${mscpdir}/build \ && cpack -G DEB CPackConfig.cmake diff --git a/docker/README.md b/docker/README.md index 07279c3..872d73f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,15 +2,17 @@ Build `mscp` in docker containers. ```console -docker build -t mscp-ubuntu:20.04 -f Dockerfile-ubuntu-20.04 . +cd .. + +docker build -t mscp-ubuntu:20.04 -f docker/Dockerfile-ubuntu-20.04 . docker run -it --rm -v (pwd):/out mscp-ubuntu:20.04 \ cp /mscp/build/mscp_0.0.0-ubuntu-20.04-x86_64.deb /out/ -docker build -t mscp-ubuntu:22.04 -f Dockerfile-ubuntu-22.04 . +docker build -t mscp-ubuntu:22.04 -f docker/Dockerfile-ubuntu-22.04 . docker run -it --rm -v (pwd):/out mscp-ubuntu:22.04 \ cp /mscp/build/mscp_0.0.0-ubuntu-22.04-x86_64.deb /out/ -docker build -t mscp-centos:8 -f Dockerfile-centos-8 . +docker build -t mscp-centos:8 -f docker/Dockerfile-centos-8 . docker run -it --rm -v (pwd):/out mscp-centos:8 \ cp /mscp/build/mscp_0.0.0-centos-8-x86_64.rpm /out/ ``` -- cgit v1.2.3