forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfe-ubuntu.Dockerfile
More file actions
106 lines (85 loc) · 4.36 KB
/
Copy pathfe-ubuntu.Dockerfile
File metadata and controls
106 lines (85 loc) · 4.36 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# This docker file build the Starrocks fe ubuntu image
# Please run this command from the git repo root directory to build:
# - Use artifact image to package runtime container:
# > DOCKER_BUILDKIT=1 docker build --build-arg ARTIFACT_SOURCE=image --build-arg ARTIFACTIMAGE=starrocks/artifacts-ubuntu:latest -f docker/dockerfiles/fe/fe-ubuntu.Dockerfile -t fe-ubuntu:latest .
# - Use locally build artifacts to package runtime container:
# > DOCKER_BUILDKIT=1 docker build --build-arg ARTIFACT_SOURCE=local --build-arg LOCAL_REPO_PATH=. -f docker/dockerfiles/fe/fe-ubuntu.Dockerfile -t fe-ubuntu:latest .
# - Build the minimal version of the image
# > DOCKER_BUILDKIT=1 docker build --build-arg ARTIFACT_SOURCE=image --build-arg ARTIFACTIMAGE=starrocks/artifacts-ubuntu:latest --build-arg MINIMAL=true -f docker/dockerfiles/fe/fe-ubuntu.Dockerfile -t fe-ubuntu-mininal:latest .
#
# The artifact source used for packing the runtime docker image
# image: copy the artifacts from a artifact docker image.
# local: copy the artifacts from a local repo. Mainly used for local development and test.
ARG ARTIFACT_SOURCE=image
# The default run_as user when starting the container
ARG RUN_AS_USER=root
# The precreated non-privileged user account, the owner of the starrocks assets
ARG USER=starrocks
# Build the minimal version of image, MINIMAL={true|false}
# NOTE:
# - if MINIMAL=true, RUN_AS_USER parameter will take no effect, the USER for the container will be set to $USER forcibly
# TODO: make MINIMAL=true as the default behavior
ARG MINIMAL=false
ARG ARTIFACTIMAGE=starrocks/artifacts-ubuntu:latest
FROM ${ARTIFACTIMAGE} AS artifacts-from-image
# create a docker build stage that copy locally build artifacts
FROM busybox:latest AS artifacts-from-local
ARG LOCAL_REPO_PATH
COPY ${LOCAL_REPO_PATH}/output/fe /release/fe_artifacts/fe
FROM artifacts-from-${ARTIFACT_SOURCE} AS artifacts
FROM ubuntu:24.04 AS base_image
ARG STARROCKS_ROOT=/opt/starrocks
ARG USER
ARG RUN_AS_USER
ARG GROUP=starrocks
ARG MINIMAL
# TODO: switch to `openjdk-##-jre` when the starrocks core is ready.
RUN OPTIONAL_PKGS="" && if [ "x$MINIMAL" = "xfalse" ] ; then OPTIONAL_PKGS="openjdk-21-jdk curl vim tree net-tools less pigz rclone" ; fi && \
apt-get update -y && apt-get install -y --no-install-recommends \
openjdk-21-jdk mysql-client tzdata locales netcat-traditional tini libssl-dev $OPTIONAL_PKGS && \
ln -fs /usr/share/zoneinfo/UTC /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata && \
locale-gen en_US.UTF-8 && \
rm -rf /var/lib/apt/lists/*
RUN touch /.dockerenv && cd /lib/jvm && \
ln -s java-21-openjdk-$(dpkg --print-architecture) java-21-openjdk
ENV JAVA_HOME=/lib/jvm/java-21-openjdk
WORKDIR $STARROCKS_ROOT
# Ubuntu 24.04 has a builtin id ubuntu (uid=1000,gid=1000), need to rename to $USER:$GROUP
# Why can't create a fresh new account with a new id?
# A: compatibility reason, previous versions run with uid=1000, if running with a different uid in a later docker image,
# local files on PVC may not be able to access any more after upgrade.
RUN if getent group 1000 >/dev/null 2>&1; then \
gname=`getent group 1000 | cut -d: -f1` && \
if [ "$gname" != "$GROUP" ]; then \
groupmod -n "$GROUP" "$gname"; \
fi ; \
else \
groupadd --gid 1000 "$GROUP"; \
fi && \
if [ "$USER" != "root" ]; then \
if id 1000 >/dev/null 2>&1; then \
username=`id -un 1000` && \
if [ "$username" != "$USER" ]; then \
usermod -l "$USER" "$username"; \
fi && \
usermod -g "$GROUP" "$USER"; \
else \
useradd --no-create-home --uid 1000 --gid "$GROUP" --shell /usr/sbin/nologin "$USER"; \
fi ; \
fi && \
chown -R "$USER":"$GROUP" "$STARROCKS_ROOT"
USER $USER
# Copy all artifacts to the runtime container image
COPY --from=artifacts --chown=$USER:$GROUP /release/fe_artifacts/ $STARROCKS_ROOT/
# Copy fe k8s scripts to the runtime container image
COPY --chown=$USER:$GROUP docker/dockerfiles/fe/*.sh $STARROCKS_ROOT/
# Create directory for FE metadata
RUN mkdir -p $STARROCKS_ROOT/fe/meta
ENTRYPOINT ["/usr/bin/tini-static", "--"]
FROM base_image AS runas_minimal_true
# Nothing to do, the USER is set to $USER in base_image
FROM base_image AS runas_minimal_false
ARG RUN_AS_USER
USER $RUN_AS_USER
FROM runas_minimal_${MINIMAL}