From 9e2bec3ce4867a81f881e38aba9b63513847967c Mon Sep 17 00:00:00 2001 From: HarrisChu <1726587+HarrisChu@users.noreply.github.com> Date: Tue, 22 Mar 2022 19:47:28 +0800 Subject: [PATCH] enhance docker build, using cache --- .github/workflows/nightly.yml | 40 +++++++++++++++++------ .github/workflows/rc.yml | 61 ++++++++++++++++++++++++++++------- docker/Dockerfile | 6 ++-- docker/Dockerfile.graphd | 23 ------------- docker/Dockerfile.metad | 23 ------------- docker/Dockerfile.storaged | 23 ------------- docker/Dockerfile.tools | 20 ------------ docker/README.md | 8 ++--- 8 files changed, 88 insertions(+), 116 deletions(-) delete mode 100644 docker/Dockerfile.graphd delete mode 100644 docker/Dockerfile.metad delete mode 100644 docker/Dockerfile.storaged delete mode 100644 docker/Dockerfile.tools diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 775b04c20a7..7769d901f17 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -62,14 +62,6 @@ jobs: docker: name: build docker image runs-on: [self-hosted, nebula] - strategy: - fail-fast: false - matrix: - service: - - graphd - - metad - - storaged - - tools steps: - uses: webiny/action-post-run@2.0.1 with: @@ -84,10 +76,38 @@ jobs: - uses: docker/build-push-action@v2 with: context: . - file: ./docker/Dockerfile.${{ matrix.service }} + file: ./docker/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + vesoft/nebula-graphd:nightly + target: graphd + push: true + - uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + vesoft/nebula-storaged:nightly + target: storaged + push: true + - uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + vesoft/nebula-metad:nightly + target: metad + push: true + - uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile platforms: linux/amd64,linux/arm64 tags: | - vesoft/nebula-${{ matrix.service }}:nightly + vesoft/nebula-tools:nightly + target: tools push: true coverage: diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml index 87de248bb29..2869d6f3f64 100644 --- a/.github/workflows/rc.yml +++ b/.github/workflows/rc.yml @@ -68,14 +68,6 @@ jobs: docker_build: name: docker-build runs-on: [self-hosted, nebula] - strategy: - fail-fast: false - matrix: - service: - - graphd - - metad - - storaged - - tools steps: - uses: webiny/action-post-run@2.0.1 with: @@ -101,15 +93,62 @@ jobs: - uses: docker/build-push-action@v2 with: context: . - file: ./docker/Dockerfile.${{ matrix.service }} + file: ./docker/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-graphd:${{ steps.tagname.outputs.tag }} + ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-graphd:${{ steps.tagname.outputs.majorver }} + ${{ steps.docker.outputs.tag }} + push: true + target: graphd + build-args: | + BRANCH=${{ steps.tagname.outputs.tag }} + VERSION=${{ steps.tagname.outputs.tagnum }} + + - uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-storaged:${{ steps.tagname.outputs.tag }} + ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-storaged:${{ steps.tagname.outputs.majorver }} + ${{ steps.docker.outputs.tag }} + push: true + target: storaged + build-args: | + BRANCH=${{ steps.tagname.outputs.tag }} + VERSION=${{ steps.tagname.outputs.tagnum }} + + - uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: | + ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-metad:${{ steps.tagname.outputs.tag }} + ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-metad:${{ steps.tagname.outputs.majorver }} + ${{ steps.docker.outputs.tag }} + push: true + target: metad + build-args: | + BRANCH=${{ steps.tagname.outputs.tag }} + VERSION=${{ steps.tagname.outputs.tagnum }} + + - uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile platforms: linux/amd64,linux/arm64 tags: | - ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-${{ matrix.service }}:${{ steps.tagname.outputs.tag }} - ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-${{ matrix.service }}:${{ steps.tagname.outputs.majorver }} + ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-tools:${{ steps.tagname.outputs.tag }} + ${{ secrets.HARBOR_REGISTRY }}/vesoft/nebula-tools:${{ steps.tagname.outputs.majorver }} ${{ steps.docker.outputs.tag }} push: true + target: tools build-args: | BRANCH=${{ steps.tagname.outputs.tag }} + VERSION=${{ steps.tagname.outputs.tagnum }} test: name: test diff --git a/docker/Dockerfile b/docker/Dockerfile index e5e907c0a43..fb79d3ab60e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,11 +1,13 @@ FROM vesoft/nebula-dev:centos7 as builder ARG BRANCH=master - +ARG VERSION= COPY . /home/nebula/BUILD RUN cd /home/nebula/BUILD/package \ - && ./package.sh -n OFF -b ${BRANCH} -c OFF + && [[ -z "${VERSION}" ]] \ + && ./package.sh -n OFF -b ${BRANCH} -t RelWithDebInfo -s TRUE -c OFF \ + || ./package.sh -n OFF -v ${VERSION} -b ${BRANCH} -t RelWithDebInfo -s TRUE -c OFF FROM centos:7 as graphd diff --git a/docker/Dockerfile.graphd b/docker/Dockerfile.graphd deleted file mode 100644 index 436264984f6..00000000000 --- a/docker/Dockerfile.graphd +++ /dev/null @@ -1,23 +0,0 @@ -FROM vesoft/nebula-dev:centos7 as builder - -COPY . /home/nebula/BUILD - -ARG BRANCH=master - -RUN cd /home/nebula/BUILD/package \ - && ./package.sh -n OFF -b ${BRANCH} -t RelWithDebInfo -s TRUE -c OFF - -FROM centos:7 - -COPY --from=builder /home/nebula/BUILD/pkg-build/cpack_output/nebula-*-common.rpm /usr/local/nebula/nebula-common.rpm -COPY --from=builder /home/nebula/BUILD/pkg-build/cpack_output/nebula-*-graph.rpm /usr/local/nebula/nebula-graphd.rpm - -WORKDIR /usr/local/nebula - -RUN rpm -ivh *.rpm \ - && mkdir -p ./{logs,data,pids} \ - && rm -rf *.rpm - -EXPOSE 9669 19669 19670 - -ENTRYPOINT ["/usr/local/nebula/bin/nebula-graphd", "--flagfile=/usr/local/nebula/etc/nebula-graphd.conf", "--daemonize=false", "--containerized=true"] diff --git a/docker/Dockerfile.metad b/docker/Dockerfile.metad deleted file mode 100644 index 6a0223f64a2..00000000000 --- a/docker/Dockerfile.metad +++ /dev/null @@ -1,23 +0,0 @@ -FROM vesoft/nebula-dev:centos7 as builder - -ARG BRANCH=master - -COPY . /home/nebula/BUILD - -RUN cd /home/nebula/BUILD/package \ - && ./package.sh -n OFF -b ${BRANCH} -t RelWithDebInfo -s TRUE -c OFF - -FROM centos:7 - -COPY --from=builder /home/nebula/BUILD/pkg-build/cpack_output/nebula-*-common.rpm /usr/local/nebula/nebula-common.rpm -COPY --from=builder /home/nebula/BUILD/pkg-build/cpack_output/nebula-*-meta.rpm /usr/local/nebula/nebula-metad.rpm - -WORKDIR /usr/local/nebula - -RUN rpm -ivh *.rpm \ - && mkdir -p ./{logs,data,pids} \ - && rm -rf *.rpm - -EXPOSE 9559 9560 19559 19560 - -ENTRYPOINT ["/usr/local/nebula/bin/nebula-metad", "--flagfile=/usr/local/nebula/etc/nebula-metad.conf", "--daemonize=false", "--containerized=true"] diff --git a/docker/Dockerfile.storaged b/docker/Dockerfile.storaged deleted file mode 100644 index 1a6ee8552bb..00000000000 --- a/docker/Dockerfile.storaged +++ /dev/null @@ -1,23 +0,0 @@ -FROM vesoft/nebula-dev:centos7 as builder - -ARG BRANCH=master - -COPY . /home/nebula/BUILD - -RUN cd /home/nebula/BUILD/package \ - && ./package.sh -n OFF -b ${BRANCH} -t RelWithDebInfo -s TRUE -c OFF - -FROM centos:7 - -COPY --from=builder /home/nebula/BUILD/pkg-build/cpack_output/nebula-*-common.rpm /usr/local/nebula/nebula-common.rpm -COPY --from=builder /home/nebula/BUILD/pkg-build/cpack_output/nebula-*-storage.rpm /usr/local/nebula/nebula-storaged.rpm - -WORKDIR /usr/local/nebula - -RUN rpm -ivh *.rpm \ - && mkdir -p ./{logs,data,pids} \ - && rm -rf *.rpm - -EXPOSE 9777 9778 9779 9780 19779 19780 - -ENTRYPOINT ["/usr/local/nebula/bin/nebula-storaged", "--flagfile=/usr/local/nebula/etc/nebula-storaged.conf", "--daemonize=false", "--containerized=true"] diff --git a/docker/Dockerfile.tools b/docker/Dockerfile.tools deleted file mode 100644 index b94f083caff..00000000000 --- a/docker/Dockerfile.tools +++ /dev/null @@ -1,20 +0,0 @@ -FROM vesoft/nebula-dev:centos7 as builder - -ARG BRANCH=master - -COPY . /home/nebula/BUILD - -RUN cd /home/nebula/BUILD/package \ - && ./package.sh -n OFF -b ${BRANCH} -t RelWithDebInfo -s TRUE -c OFF - -FROM centos:7 - -COPY --from=builder /home/nebula/BUILD/pkg-build/cpack_output/nebula-*-tool.rpm /usr/local/nebula/nebula-tool.rpm - -WORKDIR /usr/local/nebula - -RUN rpm -ivh *.rpm \ - && rm -rf *.rpm - -# default entrypoint -ENTRYPOINT ["/usr/local/nebula/bin/db_dump"] diff --git a/docker/README.md b/docker/README.md index 1e626b9b725..5f40c1fd160 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,7 +2,7 @@ Following docker images will be ready in production. -- [vesoft/nebula-graphd](https://hub.docker.com/r/vesoft/nebula-graphd): nebula-graphd service built with `Dockerfile.graphd` -- [vesoft/nebula-metad](https://hub.docker.com/r/vesoft/nebula-metad): nebula-metad service built with `Dockerfile.metad` -- [vesoft/nebula-storaged](https://hub.docker.com/r/vesoft/nebula-storaged): nebula-storaged service built with `Dockerfile.storaged` -- [vesoft/nebula-tools](https://hub.docker.com/r/vesoft/nebula-tools): nebula tools built with `Dockerfile.tools`, including db_dump, meta_dump and db_upgrader +- [vesoft/nebula-graphd](https://hub.docker.com/r/vesoft/nebula-graphd): nebula-graphd service built with `Dockerfile` and target `graphd` +- [vesoft/nebula-metad](https://hub.docker.com/r/vesoft/nebula-metad): nebula-metad service built with `Dockerfile` and target `metad` +- [vesoft/nebula-storaged](https://hub.docker.com/r/vesoft/nebula-storaged): nebula-storaged service built with `Dockerfile` and target `storaged` +- [vesoft/nebula-tools](https://hub.docker.com/r/vesoft/nebula-tools): nebula tools built with `Dockerfile` and target `tools`, including db_dump, meta_dump and db_upgrader