blob: 912ddf8755a9b7b0baaa2c18699c2e4fd3e457ad [file]
# syntax=docker/dockerfile:1
#
# 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.
#
# Dockerfile for HugeGraph Server
# 1st stage: build source code
FROM --platform=$BUILDPLATFORM maven:3.9.16-eclipse-temurin-17 AS build
WORKDIR /pkg
COPY . .
ARG MAVEN_ARGS
ARG MAVEN_PROJECTS="hugegraph-server/hugegraph-dist,hugegraph-pd/hg-pd-dist,hugegraph-store/hg-store-dist"
ARG SOURCE_REVISION=local
RUN --mount=type=cache,id=hugegraph-maven-${SOURCE_REVISION},target=/root/.m2,sharing=locked \
mvn install -pl "$MAVEN_PROJECTS" \
-am $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
FROM eclipse-temurin:17-jdk-jammy
# Local Arthas attach requires the JDK attach and compiler modules.
LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
# TODO: use g1gc or zgc as default
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" \
HUGEGRAPH_HOME="hugegraph-server" \
STDOUT_MODE="true"
WORKDIR /hugegraph-server/
# 1. Install runtime dependencies
# Note: iproute2 provides `ss`, which the bin/util.sh port preflight needs. The
# jammy base image ships neither ss nor netstat, so without it the preflight is
# permanently inconclusive and a duplicate start is no longer caught. It
# replaces lsof, which no shipped script calls any more.
ARG RUNTIME_DEPS_EPOCH=1
RUN apt-get -q update \
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
dumb-init \
procps \
curl \
iproute2 \
vim \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 2. Run as a fixed non-root user; USER must be numeric so Kubernetes can
# verify runAsNonRoot. The data and log directories exist in the image so
# named volumes mounted there start out owned by that user. See
# docker/README.md before upgrading volumes written by an older image.
ARG HG_UID=10001
ARG HG_GID=10001
RUN groupadd --system --gid "${HG_GID}" hugegraph \
&& useradd --system --uid "${HG_UID}" --gid hugegraph --no-create-home \
--home-dir /hugegraph-server --shell /usr/sbin/nologin hugegraph \
&& install -d -o "${HG_UID}" -g "${HG_GID}" /hugegraph-server /hugegraph-server/rocksdb-data /hugegraph-server/logs
COPY --from=build --chown=${HG_UID}:${HG_GID} /pkg/hugegraph-server/apache-hugegraph-server-*/ /hugegraph-server/
USER ${HG_UID}:${HG_GID}
RUN sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties
# 3. Init docker script
COPY --chown=${HG_UID}:${HG_GID} hugegraph-server/hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts
COPY --chown=${HG_UID}:${HG_GID} hugegraph-server/hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts
COPY --chown=${HG_UID}:${HG_GID} --chmod=755 hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh .
EXPOSE 8080
VOLUME /hugegraph-server
HEALTHCHECK --interval=15s --timeout=10s --start-period=90s --retries=3 \
CMD curl -fsS http://localhost:8080/versions >/dev/null
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["./docker-entrypoint.sh"]