-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
47 lines (36 loc) · 1.11 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# builder
FROM alpine as builder
ARG kafka_version=3.6.1
ARG scala_version=2.13
ENV dl_url="https://archive.apache.org/dist/kafka/${kafka_version}/kafka_${scala_version}-${kafka_version}.tgz"
RUN set -ex \
; mkdir -pv /tmp/kfk \
; wget "$dl_url" -O /tmp/kfk/kafka.tgz \
; cd /tmp/kfk && tar -xf kafka.tgz \
; rm -f /tmp/kfk/kafka.tgz \
; mv kafka_* kafka
# container
FROM eclipse-temurin:21-jre-noble
ENV KAFKA_HOME="/opt/kafka" \
KAFKA_CONF_FILE="/etc/kafka/server.properties"
RUN set -ex \
; if id -nu 1000 &> /dev/null ; then \
user_name=$(id -nu 1000) ; \
echo user_name: $user_name ; \
usermod -u 3000 $user_name ; \
groupmod -g 3000 $user_name ; \
fi \
; useradd kafka --uid 1000 -m -s /bin/bash \
; mkdir -pv "/etc/kafka" && chown -R 1000:1000 "/etc/kafka"
COPY --from=0 --chown=1000:1000 /tmp/kfk/kafka "$KAFKA_HOME"
RUN set -ex \
; apt-get update \
; apt-get install \
iproute2 -y --no-install-recommends \
; rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /entrypoint.sh
WORKDIR $KAFKA_HOME
EXPOSE 9092
# USER 1000
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "start" ]