blob: 2af4d1435a8ff67d2f25a90b90286617fd63160a [file]
#
# 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.
#
# Connector-runtime image — a separate process that talks HTTP+CloudEvents to the
# EventMesh runtime and runs source/sink connectors. Built from `dist-connector`
# (connector-runtime jar + deps + every connector plugin under plugin/connector/).
# Same builder constraints as docker/Dockerfile (system gradle 8.5 + JDK 21).
# Build-stage runs as root; the runtime stage below drops to a non-root user.
FROM gradle:8.5.0-jdk21 AS builder
USER root
WORKDIR /build
COPY . .
RUN gradle clean dist-connector --no-daemon
# Runtime: ConnectorApplication loads connectors via Class.forName, so bin/start-connector.sh
# flattens plugin/connector/**/*.jar onto the classpath (find is required by that script).
FROM eclipse-temurin:21-jre
# findutils: `find` is required by bin/start-connector.sh; procps ships pgrep
# (used by the HEALTHCHECK below). C.UTF-8 comes with the base image
# (issue #5350: no locales package / localedef needed).
RUN apt-get update && apt-get install -y --no-install-recommends procps findutils \
&& rm -rf /var/lib/apt/lists/*
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# Run the JVM as a dedicated non-root user (issue #5350).
RUN groupadd --gid 10002 connector \
&& useradd --uid 10002 --gid connector --home-dir /data/app/connector --shell /usr/sbin/nologin connector
WORKDIR /data/app/connector
COPY --from=builder --chown=connector:connector /build/dist-connector ./
RUN chmod +x bin/*.sh
# Connector admin port is opt-in (CONNECTOR_ADMIN_PORT=0 = off by default). Expose 8083 as the
# conventional port for operators who enable it; the connector otherwise makes only outbound calls.
EXPOSE 8083
# Liveness probe (issue #5350). The admin port is off by default, so an HTTP
# probe would false-negative for the default config; check the JVM process
# instead. Swap in an HTTP check once the admin API grows a documented health
# route and the port is enabled.
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
CMD pgrep -f ConnectorApplication >/dev/null || exit 1
ENV DOCKER=true
ENV EVENTMESH_HOME=/data/app/connector
ENV EVENTMESH_LOG_HOME=/data/app/connector/logs
ENV CONFPATH=/data/app/connector/conf
ENV EVENTMESH_RUNTIME_URL=http://localhost:10105
ENV CONNECTOR_ADMIN_PORT=0
ENV CONNECTOR_OFFSET_MODE=remote
ENV CONNECTOR_OFFSET_PATH=/data/app/connector/data/connector-offset
# Connector -D flags, e.g. -Dconnector.1.class=... -Dconnector.1.mode=source -Dconnector.1.topic=t
ENV CONNECTOR_OPTS=""
# Extra -D flags (TLS, …)
# For container memory limits consider -XX:MaxRAMPercentage=70.
ENV JAVA_OPTS=""
# Persistent state: connector offsets (CONNECTOR_OFFSET_PATH) when running in
# standalone offset mode (issue #5350).
VOLUME ["/data/app/connector/data"]
USER connector
CMD ["bash", "bin/start-connector.sh"]