-
Notifications
You must be signed in to change notification settings - Fork 215
Expand file tree
/
Copy pathDockerfile
More file actions
115 lines (104 loc) · 5.14 KB
/
Dockerfile
File metadata and controls
115 lines (104 loc) · 5.14 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
107
108
109
110
111
112
113
114
115
#
# 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.
#
# ---------------------------------------------------------------------
# Apache Auron build environment on Debian 11
# ---------------------------------------------------------------------
FROM debian:11
LABEL maintainer="Apache Auron Team"
LABEL description="Debian 11 build environment for Auron project"
# ---------------------------------------------------------------------
# Environment setup
# ---------------------------------------------------------------------
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV TZ=UTC
ENV DEBIAN_FRONTEND=noninteractive
# ---------------------------------------------------------------------
# Update system and install basic packages
# ---------------------------------------------------------------------
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
build-essential \
software-properties-common \
curl wget git unzip zip \
pkg-config \
ca-certificates openssl libssl-dev zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
# ---------------------------------------------------------------------
# Verify GCC / G++
# ---------------------------------------------------------------------
RUN gcc --version && g++ --version
# ---------------------------------------------------------------------
# Install Rust (nightly toolchain)
# ---------------------------------------------------------------------
RUN curl https://sh.rustup.rs -sSf -o rustup-init && \
chmod +x rustup-init && \
./rustup-init -y --default-toolchain nightly-2025-05-09-x86_64-unknown-linux-gnu && \
rm rustup-init
ENV PATH="/root/.cargo/bin:${PATH}"
# ---------------------------------------------------------------------
# Install Java (multiple Temurin OpenJDK versions)
# NOTE: JDK 8 and JDK 11 are EOL. Prefer JDK 17+ for new usage.
# ---------------------------------------------------------------------
ARG JDK_VERSIONS="8 11 17 21"
ARG DEFAULT_JDK="8"
ENV JAVA_INSTALL_BASE="/opt/java"
RUN set -eux; \
mkdir -p "${JAVA_INSTALL_BASE}"; \
for v in ${JDK_VERSIONS}; do \
url="https://github.com/adoptium/temurin${v}-binaries/releases/latest/download/OpenJDK${v}U-jdk_x64_linux_hotspot.tar.gz"; \
curl -fsSL "$url" -o /tmp/temurin.tar.gz || { echo "Failed to download JDK ${v}"; exit 1; }; \
mkdir -p "${JAVA_INSTALL_BASE}/temurin-${v}"; \
tar -xzf /tmp/temurin.tar.gz -C "${JAVA_INSTALL_BASE}/temurin-${v}" --strip-components=1; \
done; \
rm -f /tmp/temurin.tar.gz; \
alt="$(command -v update-alternatives || command -v alternatives)"; \
for v in ${JDK_VERSIONS}; do \
"$alt" --install /usr/bin/java java "${JAVA_INSTALL_BASE}/temurin-${v}/bin/java" $((100 + v)); \
"$alt" --install /usr/bin/javac javac "${JAVA_INSTALL_BASE}/temurin-${v}/bin/javac" $((100 + v)); \
done; \
"$alt" --set java "${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}/bin/java"; \
"$alt" --set javac "${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}/bin/javac"
# Default JAVA_HOME is set at build time; run `source /etc/profile.d/java.sh` after set-java to update.
ENV JAVA_HOME="${JAVA_INSTALL_BASE}/temurin-${DEFAULT_JDK}"
ENV PATH="${JAVA_HOME}/bin:${PATH}"
# Helper to switch JDK at runtime (e.g., set-java 11)
RUN printf '%s\n' \
'#!/usr/bin/env bash' \
'set -euo pipefail' \
'ver="${1:-}"' \
'if [ -z "$ver" ]; then echo "usage: set-java <version>"; exit 2; fi' \
'base="/opt/java/temurin-${ver}"' \
'if [ ! -x "${base}/bin/java" ]; then echo "JDK ${ver} not installed"; exit 1; fi' \
'alt="$(command -v update-alternatives || command -v alternatives)"' \
'"$alt" --set java "${base}/bin/java"' \
'"$alt" --set javac "${base}/bin/javac"' \
'echo "Java switched to version ${ver}. Run '\''source /etc/profile.d/java.sh'\'' to update JAVA_HOME."' \
> /usr/local/bin/set-java && chmod +x /usr/local/bin/set-java
# Dynamic JAVA_HOME for interactive shells
RUN printf '%s\n' \
'export JAVA_HOME="$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")"' \
'export PATH="${JAVA_HOME}/bin:${PATH}"' \
> /etc/profile.d/java.sh
# ---------------------------------------------------------------------
# Set working directory
# ---------------------------------------------------------------------
WORKDIR /auron
# ---------------------------------------------------------------------
# Default command
# ---------------------------------------------------------------------
CMD ["/bin/bash"]