From 38a6decc257f713876392b7aa93a6f64d9019fb3 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Tue, 3 Mar 2020 16:06:34 +0800 Subject: [PATCH] build: docker-centos-build: run as root so that output file ownership can be properly changed The Dockerfile was moved to a separate repo for maintenance --- .circleci/Dockerfile | 38 -------------------------------------- .circleci/config.yml | 20 ++++++++++---------- Makefile | 8 ++++---- 3 files changed, 14 insertions(+), 52 deletions(-) delete mode 100644 .circleci/Dockerfile diff --git a/.circleci/Dockerfile b/.circleci/Dockerfile deleted file mode 100644 index a64293460f..0000000000 --- a/.circleci/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -FROM centos:7 -MAINTAINER Yousong Zhou - -RUN true \ - && yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ - && yum install -y git wget \ - && yum groupinstall -y "Development Tools" \ - && : ceph for cmd/host \ - && rpm --import 'https://download.ceph.com/keys/release.asc' \ - && yum install -y https://download.ceph.com/rpm-luminous/el7/noarch/ceph-release-1-1.el7.noarch.rpm \ - && yum install -y libcephfs-devel librbd-devel librados-devel \ - && yum clean all - -WORKDIR /opt -RUN true \ - && wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz \ - && tar xzf go1.13.3.linux-amd64.tar.gz \ - && rm -vf go1.13.3.linux-amd64.tar.gz \ - && true -ENV GOROOT="/opt/go" -ENV PATH="/opt/go/bin:${PATH}" - -RUN useradd -c "OneCloud Builder" --create-home --home-dir /home/build --shell /bin/bash build -ENV HOME /home/build -WORKDIR /home/build -USER build - -ENV GOPATH="/home/build/go" -ENV PATH="${GOPATH}/bin:${PATH}" - -RUN true \ - && mkdir -p "$GOPATH" \ - && d="$GOPATH/src/golang.org/x/tools" \ - && mkdir -p "$d" \ - && git clone --branch yun --depth 8 https://github.com/yousong/tools "$d" \ - && cd "$d" \ - && go install ./cmd/goimports \ - && true diff --git a/.circleci/config.yml b/.circleci/config.yml index 354631a9a0..8fc4ee300c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,10 +5,10 @@ version: 2 jobs: check: docker: - - image: yunionio/onecloud-ci:v1.0.3 + - image: yunionio/centos-build:1.0-1 environment: ONECLOUD_CI_BUILD: "1" - working_directory: /home/build/go/src/yunion.io/x/onecloud + working_directory: /root/go/onecloud steps: - checkout - run: @@ -18,7 +18,7 @@ jobs: requires: - check docker: - - image: yunionio/onecloud-ci:v1.0.2 + - image: yunionio/centos-build:1.0-1 environment: ONECLOUD_CI_BUILD: "1" @@ -26,14 +26,14 @@ jobs: #### expecting it in the form of #### /go/src/github.com/circleci/go-tool #### /go/src/bitbucket.org/circleci/go-tool - working_directory: /home/build/go/src/yunion.io/x/onecloud + working_directory: /root/go/onecloud parallelism: 4 steps: - checkout - restore_cache: key: onecloud-build-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }} paths: - - /home/build/.cache/go-build + - /root/.cache/go-build - run: command: | targets="$(circleci tests glob "cmd/*" | grep -v cmd/host-image | circleci tests split)" @@ -43,7 +43,7 @@ jobs: - save_cache: key: onecloud-build-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }} paths: - - /home/build/.cache/go-build + - /root/.cache/go-build - store_artifacts: path: _output/ @@ -51,16 +51,16 @@ jobs: requires: - check docker: - - image: yunionio/onecloud-ci:v1.0.2 + - image: yunionio/centos-build:1.0-1 environment: GO111MODULE: "on" - working_directory: /home/build/go/src/yunion.io/x/onecloud + working_directory: /root/go/onecloud steps: - checkout - restore_cache: key: onecloud-test-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }} paths: - - /home/build/.cache/go-build + - /root/.cache/go-build - run: name: unit_test command: | @@ -68,7 +68,7 @@ jobs: - save_cache: key: onecloud-test-cache-{{ checksum "go.mod" }}-{{ checksum "Makefile" }} paths: - - /home/build/.cache/go-build + - /root/.cache/go-build workflows: version: 2 diff --git a/Makefile b/Makefile index f51b89762e..b492206518 100644 --- a/Makefile +++ b/Makefile @@ -192,13 +192,13 @@ mod: go mod vendor -v -DOCKER_BUILD_IMAGE_VERSION?=latest +DOCKER_BUILD_IMAGE_VERSION?=1.0-1 define dockerCentOSBuildCmd set -o xtrace set -o errexit set -o pipefail -cd /home/build/onecloud +cd /root/onecloud export GOFLAGS=-mod=vendor make $(1) chown -R $(shell id -u):$(shell id -g) _output @@ -210,8 +210,8 @@ docker-centos-build: docker run \ --name onecloud-ci-build \ --rm \ - --volume $(CURDIR):/home/build/onecloud \ - yunionio/onecloud-ci:$(DOCKER_BUILD_IMAGE_VERSION) \ + --volume $(CURDIR):/root/onecloud \ + registry.cn-beijing.aliyuncs.com/yunionio/centos-build:$(DOCKER_BUILD_IMAGE_VERSION) \ /bin/bash -c "$$dockerCentOSBuildCmd" chown -R $$(id -u):$$(id -g) _output ls -lh _output/bin