perf(docker): improve all images build cache efficiency (#3025)
- Fix .gitattribut -> .gitattributes typo in .dockerignore - Fix **/*.tar.gz* -> **/*.tar.gz (remove unintended trailing wildcard) - Remove **/target/dist/ (redundant, already covered by **/target/) - Restore cron to apt-get install in all 4 Dockerfiles to keep the existing start-hugegraph.sh -m true monitor path working
This commit is contained in:
parent
66e5339e3a
commit
8d095e1d99
|
|
@ -0,0 +1,60 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# IMPORTANT: .dockerignore does NOT inherit .gitignore — patterns must be restated.
|
||||
|
||||
# Build output
|
||||
**/target/
|
||||
|
||||
# Pre-extracted release dirs / archives
|
||||
apache-hugegraph-*/
|
||||
**/*.tar
|
||||
**/*.tar.gz
|
||||
**/*.zip
|
||||
**/*.war
|
||||
|
||||
# IDE / OS
|
||||
.idea/
|
||||
.vscode/
|
||||
**/*.iml
|
||||
**/*.iws
|
||||
**/.DS_Store
|
||||
|
||||
# Build / runtime artifacts
|
||||
**/logs/
|
||||
**/*.log
|
||||
**/*.class
|
||||
**/gen-java/
|
||||
**/upload-files/
|
||||
**/build/
|
||||
**/node_modules/
|
||||
|
||||
# Env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Git internals
|
||||
.git
|
||||
.gitignore
|
||||
.gitattributes
|
||||
.github
|
||||
|
||||
# Compose / docs not needed in build context
|
||||
**/docker-compose*.yml
|
||||
**/docker-compose*.yaml
|
||||
**/*.md
|
||||
docs/
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
name: "Docker Build CI"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'release-*'
|
||||
pull_request:
|
||||
paths:
|
||||
- '**/Dockerfile*'
|
||||
- '.dockerignore'
|
||||
|
||||
jobs:
|
||||
docker-build:
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
dockerfile:
|
||||
- hugegraph-pd/Dockerfile
|
||||
- hugegraph-store/Dockerfile
|
||||
- hugegraph-server/Dockerfile
|
||||
- hugegraph-server/Dockerfile-hstore
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build ${{ matrix.dockerfile }}
|
||||
run: |
|
||||
docker build -f ${{ matrix.dockerfile }} .
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
@ -19,12 +20,15 @@
|
|||
# 1st stage: build source code
|
||||
FROM maven:3.9.0-eclipse-temurin-11 AS build
|
||||
|
||||
COPY . /pkg
|
||||
WORKDIR /pkg
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG MAVEN_ARGS
|
||||
|
||||
RUN mvn package $MAVEN_ARGS -e -B -ntp -Dmaven.test.skip=true -Dmaven.javadoc.skip=true && pwd && ls -l && rm \
|
||||
./hugegraph-server/*.tar.gz && rm ./hugegraph-pd/*.tar.gz && rm ./hugegraph-store/*.tar.gz
|
||||
RUN --mount=type=cache,target=/root/.m2 \
|
||||
mvn package $MAVEN_ARGS -e -B -ntp -Dmaven.test.skip=true -Dmaven.javadoc.skip=true \
|
||||
&& rm ./hugegraph-server/*.tar.gz ./hugegraph-pd/*.tar.gz ./hugegraph-store/*.tar.gz
|
||||
|
||||
# 2nd stage: runtime env
|
||||
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
|
||||
|
|
@ -38,14 +42,10 @@ ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:Max
|
|||
HUGEGRAPH_HOME="hugegraph-pd" \
|
||||
STDOUT_MODE="true"
|
||||
|
||||
#COPY . /hugegraph/hugegraph-pd
|
||||
WORKDIR /hugegraph-pd/
|
||||
|
||||
# 1. Install environment and init HugeGraph Sever
|
||||
RUN set -x \
|
||||
&& rm /var/lib/dpkg/info/libc-bin.* \
|
||||
&& apt-get -q clean \
|
||||
&& apt-get -q update \
|
||||
# 1. Install runtime dependencies
|
||||
RUN apt-get -q update \
|
||||
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
|
||||
dumb-init \
|
||||
procps \
|
||||
|
|
@ -54,9 +54,7 @@ RUN set -x \
|
|||
vim \
|
||||
cron \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& service cron start \
|
||||
&& pwd && cd /hugegraph-pd/
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 2. Init docker script
|
||||
COPY hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh .
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
@ -19,15 +20,18 @@
|
|||
# 1st stage: build source code
|
||||
FROM maven:3.9.0-eclipse-temurin-11 AS build
|
||||
|
||||
COPY . /pkg
|
||||
WORKDIR /pkg
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG MAVEN_ARGS
|
||||
|
||||
RUN mvn package $MAVEN_ARGS -e -B -ntp -Dmaven.test.skip=true -Dmaven.javadoc.skip=true && pwd && ls -l && rm \
|
||||
./hugegraph-server/*.tar.gz && rm ./hugegraph-pd/*.tar.gz && rm ./hugegraph-store/*.tar.gz
|
||||
RUN --mount=type=cache,target=/root/.m2 \
|
||||
mvn package $MAVEN_ARGS -e -B -ntp -Dmaven.test.skip=true -Dmaven.javadoc.skip=true \
|
||||
&& rm ./hugegraph-server/*.tar.gz ./hugegraph-pd/*.tar.gz ./hugegraph-store/*.tar.gz
|
||||
|
||||
# 2nd stage: runtime env
|
||||
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
|
||||
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
|
||||
FROM eclipse-temurin:11-jre-jammy
|
||||
|
||||
COPY --from=build /pkg/hugegraph-server/apache-hugegraph-server-*/ /hugegraph-server/
|
||||
|
|
@ -39,14 +43,10 @@ ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:Max
|
|||
HUGEGRAPH_HOME="hugegraph-server" \
|
||||
STDOUT_MODE="true"
|
||||
|
||||
#COPY . /hugegraph/hugegraph-server
|
||||
WORKDIR /hugegraph-server/
|
||||
|
||||
# 1. Install environment and init HugeGraph Sever
|
||||
RUN set -x \
|
||||
&& rm /var/lib/dpkg/info/libc-bin.* \
|
||||
&& apt-get -q clean \
|
||||
&& apt-get -q update \
|
||||
# 1. Install runtime dependencies and configure server
|
||||
RUN apt-get -q update \
|
||||
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
|
||||
dumb-init \
|
||||
procps \
|
||||
|
|
@ -56,8 +56,6 @@ RUN set -x \
|
|||
cron \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& service cron start \
|
||||
&& pwd && cd /hugegraph-server/ \
|
||||
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties
|
||||
|
||||
# 2. Init docker script
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
@ -15,19 +16,22 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Dockerfile for HugeGraph Server
|
||||
# Dockerfile for HugeGraph Server (hstore backend)
|
||||
# 1st stage: build source code
|
||||
FROM maven:3.9.0-eclipse-temurin-11 AS build
|
||||
|
||||
COPY . /pkg
|
||||
WORKDIR /pkg
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG MAVEN_ARGS
|
||||
|
||||
RUN mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l && rm \
|
||||
./hugegraph-server/*.tar.gz && rm ./hugegraph-pd/*.tar.gz && rm ./hugegraph-store/*.tar.gz
|
||||
RUN --mount=type=cache,target=/root/.m2 \
|
||||
mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true \
|
||||
&& rm ./hugegraph-server/*.tar.gz ./hugegraph-pd/*.tar.gz ./hugegraph-store/*.tar.gz
|
||||
|
||||
# 2nd stage: runtime env
|
||||
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
|
||||
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
|
||||
FROM eclipse-temurin:11-jre-jammy
|
||||
|
||||
COPY --from=build /pkg/hugegraph-server/apache-hugegraph-server-*/ /hugegraph-server/
|
||||
|
|
@ -41,12 +45,10 @@ LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
|
|||
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" \
|
||||
HUGEGRAPH_HOME="hugegraph-server"
|
||||
|
||||
#COPY . /hugegraph/hugegraph-server
|
||||
WORKDIR /hugegraph-server/
|
||||
|
||||
# 1. Install environment and init HugeGraph Sever
|
||||
RUN set -x \
|
||||
&& apt-get -q update \
|
||||
# 1. Install runtime dependencies and configure server
|
||||
RUN apt-get -q update \
|
||||
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
|
||||
dumb-init \
|
||||
procps \
|
||||
|
|
@ -56,8 +58,6 @@ RUN set -x \
|
|||
cron \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& service cron start \
|
||||
&& pwd && cd /hugegraph-server/ \
|
||||
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties
|
||||
|
||||
# 2. Init docker script
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
@ -19,12 +20,15 @@
|
|||
# 1st stage: build source code
|
||||
FROM maven:3.9.0-eclipse-temurin-11 AS build
|
||||
|
||||
COPY . /pkg
|
||||
WORKDIR /pkg
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG MAVEN_ARGS
|
||||
|
||||
RUN mvn package $MAVEN_ARGS -e -B -ntp -Dmaven.test.skip=true -Dmaven.javadoc.skip=true && pwd && ls -l && rm \
|
||||
./hugegraph-server/*.tar.gz && rm ./hugegraph-pd/*.tar.gz && rm ./hugegraph-store/*.tar.gz
|
||||
RUN --mount=type=cache,target=/root/.m2 \
|
||||
mvn package $MAVEN_ARGS -e -B -ntp -Dmaven.test.skip=true -Dmaven.javadoc.skip=true \
|
||||
&& rm ./hugegraph-server/*.tar.gz ./hugegraph-pd/*.tar.gz ./hugegraph-store/*.tar.gz
|
||||
|
||||
# 2nd stage: runtime env
|
||||
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
|
||||
|
|
@ -38,14 +42,10 @@ ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:Max
|
|||
HUGEGRAPH_HOME="hugegraph-store" \
|
||||
STDOUT_MODE="true"
|
||||
|
||||
#COPY . /hugegraph/hugegraph-store
|
||||
WORKDIR /hugegraph-store/
|
||||
|
||||
# 1. Install environment and init HugeGraph Sever
|
||||
RUN set -x \
|
||||
&& rm /var/lib/dpkg/info/libc-bin.* \
|
||||
&& apt-get -q clean \
|
||||
&& apt-get -q update \
|
||||
# 1. Install runtime dependencies
|
||||
RUN apt-get -q update \
|
||||
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
|
||||
dumb-init \
|
||||
procps \
|
||||
|
|
@ -54,9 +54,7 @@ RUN set -x \
|
|||
vim \
|
||||
cron \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& service cron start \
|
||||
&& pwd && cd /hugegraph-store/
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 2. Init docker script
|
||||
COPY hugegraph-store/hg-store-dist/docker/docker-entrypoint.sh .
|
||||
|
|
|
|||
Loading…
Reference in New Issue