Repository navigation
Expand file tree
/
Copy pathDockerfile.ubi8
More file actions
192 lines (166 loc) · 8.22 KB
/
Copy pathDockerfile.ubi8
File metadata and controls
192 lines (166 loc) · 8.22 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Base image arguments
ARG BASE_REGISTRY=registry.access.redhat.com
ARG BASE_IMAGE=ubi8/ubi
ARG BASE_TAG=latest
ARG COPILOT_VERSION=latest
#global argument for tomcat
ARG TOMCAT_VERSION=11.0.29
# Which tomcat-builder variant to base on. Empty = the standard image; pass
# --build-arg TOMCAT_TAG_SUFFIX=-fips
# for the FIPS 140-3 variant. Only the SUFFIX crosses the workflow boundary, so
# TOMCAT_VERSION above stays the single source of truth for the version.
# A -fips base MUST be paired with SEMOSS_FIPS=true, or the war brings its own
# BouncyCastle into WEB-INF/lib beside the validated bc-fips and the result
# boots cleanly while being non-compliant.
ARG TOMCAT_TAG_SUFFIX=
ARG JAVA_HOME=/usr/lib/jvm/zulu25
ARG MAVEN_HOME=/opt/apache-maven-3.10.0
#setting up the tomcat builder for later below. this is for env var expansion.
FROM quay.io/semoss/tomcat-builder:${TOMCAT_VERSION}${TOMCAT_TAG_SUFFIX} AS tomcat_builder
ARG COPILOT_VERSION
# Provided automatically by buildx (amd64/arm64). Defaults to amd64 when building
# without buildx (TARGETARCH unset).
ARG TARGETARCH
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends ca-certificates curl tar \
&& rm -rf /var/lib/apt/lists/* \
&& case "${TARGETARCH:-amd64}" in \
arm64) copilot_arch="arm64" ;; \
*) copilot_arch="x64" ;; \
esac \
&& tmp="$(mktemp -d)" \
&& case "${COPILOT_VERSION}" in \
latest) copilot_url="https://github.com/github/copilot-cli/releases/latest/download/copilot-linux-${copilot_arch}.tar.gz" ;; \
*) copilot_url="https://github.com/github/copilot-cli/releases/download/${COPILOT_VERSION}/copilot-linux-${copilot_arch}.tar.gz" ;; \
esac \
&& curl -fsSL -o "$tmp/copilot.tgz" "$copilot_url" \
&& tar -xzf "$tmp/copilot.tgz" -C "$tmp" \
&& install -m 0755 "$tmp/copilot" /usr/local/bin/copilot \
&& rm -rf "$tmp" \
&& chown 1001:0 /usr/local/bin/copilot
# FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS base
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS mavenpuller
# Define environment variables in this stage
ARG TOMCAT_VERSION
ARG JAVA_HOME
ARG MAVEN_HOME
ARG SEMOSS_VERSION
# Selects the fips / libraries-fips Maven classifiers in
# update_latest_dev.sh. Must be true whenever TOMCAT_TAG is a -fips tag.
ARG SEMOSS_FIPS=false
ENV JAVA_HOME=${JAVA_HOME}
ENV TOMCAT_HOME=/opt/apache-tomcat-${TOMCAT_VERSION}
ENV MAVEN_HOME=${MAVEN_HOME}
ENV PATH=$PATH:$MAVEN_HOME/bin:$TOMCAT_HOME/bin:$JAVA_HOME/bin
ENV SEMOSS_VERSION=${SEMOSS_VERSION}
ENV SEMOSS_FIPS=${SEMOSS_FIPS}
# Get tomcat, maven and java from another image called tomcat-builder
COPY --from=tomcat_builder /opt /opt
COPY --from=tomcat_builder /usr/lib/jvm/zulu25 /usr/lib/jvm/zulu25
RUN yum update -y \
&& yum install -y git curl unzip lsof procps-ng \
&& mkdir /opt/semosshome \
&& cd /opt && git clone https://github.com/SEMOSS/semoss-artifacts \
&& chmod 777 /opt/semoss-artifacts/artifacts/scripts/*.sh \
&& /opt/semoss-artifacts/artifacts/scripts/update_latest_dev.sh \
&& chmod 777 /opt/semosshome/config/Chromedriver/* \
&& sed -i "s/tomcat.util.scan.StandardJarScanFilter.jarsToSkip=/tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*.jar,/g" $TOMCAT_HOME/conf/catalina.properties;
# Create a group 'root' with GID 0 if it doesn't exist (it should by default)
RUN groupadd -g 0 root || true
RUN useradd -u 1001 -r -g 0 -d /opt/semosshome -s /bin/bash \
-c "Default Application User" default && \
chown -R 1001:0 /opt/semosshome
RUN mkdir /opt/chroot
RUN chown -R 1001:0 /opt
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS final
LABEL maintainer="semoss@semoss.org"
# From JAVA/tomcat
ARG TOMCAT_VERSION
ARG JAVA_HOME
ARG MAVEN_HOME
ENV JAVA_HOME=${JAVA_HOME}
ENV TOMCAT_VERSION=${TOMCAT_VERSION}
ENV TOMCAT_HOME=/opt/apache-tomcat-${TOMCAT_VERSION}
ENV VIRTUAL_ENV="/usr/lib/python/semossvenv"
ENV PATH=$VIRTUAL_ENV/bin:$PATH:$MAVEN_HOME/bin:$TOMCAT_HOME/bin:$JAVA_HOME/bin:/opt/semoss-artifacts/artifacts/scripts
ENV LANG='en_US.UTF-8'
ENV LANGUAGE='en_US:en'
ENV LC_ALL='en_US.UTF-8'
COPY --from=tomcat_builder /usr/lib/jvm/zulu25 /usr/lib/jvm/zulu25
COPY --from=tomcat_builder /usr/local/bin/copilot /usr/local/bin/copilot
COPY --from=tomcat_builder /usr/bin/openshell /usr/local/bin/openshell
RUN yum update -y \
&& yum install -y git curl unzip lsof vim nano procps-ng ca-certificates tar gzip \
&& curl https://rclone.org/install.sh | bash \
&& chmod 755 /usr/bin/rclone
## TODO - Chrome installation for UBI8 would be different.
# RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
# && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list \
# && yum update \
# && yum install -y google-chrome-stable bash
COPY --from=mavenpuller --chown=1001:0 /opt /opt
COPY --from=quay.io/semoss/python-builder:3.14-cpu /usr/lib/python /usr/lib/python
# ---------------------------------------------------------------------------
# Node.js runtime for the agent-only ExecuteNodeCode execution environment.
# NodeUtils resolves <NODE_HOME>/bin/node, so this must be a plain nodejs.org
# dist layout rather than a distro package. The curated js/node_env packages
# are installed at build time so the running container never needs npm or
# registry access (guarded: js/ only ships in the semosshome artifact once its
# assembly includes it). AGENT_DEFAULT_TOOLS_ENABLE_NODE is seeded false so
# the runtime env passthrough scripts have a line to sed, matching the other
# agent tool flags.
ARG NODE_VERSION=24.22.1
# The npm bundled with Node 24.22.1 (11.19.1) ships vulnerable brace-expansion,
# undici and http-cache-semantics. Track the newest 11.x (11.21.1+ bundles the
# fixed copies) so patch releases land on rebuild; pin an exact version to freeze.
ARG NPM_VERSION=11
ENV NODE_HOME=/opt/node
RUN set -eux; \
case "$(uname -m)" in \
x86_64) nodeArch=x64 ;; \
aarch64|arm64) nodeArch=arm64 ;; \
*) echo "unsupported architecture $(uname -m) for the node runtime"; exit 1 ;; \
esac; \
nodeTar="node-v${NODE_VERSION}-linux-${nodeArch}.tar.gz"; \
cd /tmp; \
curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/${nodeTar}"; \
curl -fsSL -o node-SHASUMS256.txt "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt"; \
grep " ${nodeTar}" node-SHASUMS256.txt | sha256sum -c -; \
mkdir -p "/opt/node-v${NODE_VERSION}"; \
tar -xzf "${nodeTar}" -C "/opt/node-v${NODE_VERSION}" --strip-components=1; \
ln -sfn "/opt/node-v${NODE_VERSION}" /opt/node; \
rm -f "${nodeTar}" node-SHASUMS256.txt; \
/opt/node/bin/node --version; \
PATH="/opt/node/bin:$PATH" /opt/node/bin/npm install -g "npm@${NPM_VERSION}" --no-audit --no-fund; \
PATH="/opt/node/bin:$PATH" /opt/node/bin/npm --version; \
if [ -f /opt/semosshome/js/node_env/package-lock.json ]; then \
cd /opt/semosshome/js/node_env; \
PATH="/opt/node/bin:$PATH" /opt/node/bin/npm ci --omit=dev --no-audit --no-fund; \
chown -R 1001:0 /opt/semosshome/js; \
fi; \
if ! grep -q "^AGENT_DEFAULT_TOOLS_ENABLE_NODE" /opt/semosshome/RDF_Map.prop; then \
printf 'AGENT_DEFAULT_TOOLS_ENABLE_NODE\tfalse\n' >> /opt/semosshome/RDF_Map.prop; \
fi
#LOCALE
# Installing "glibc-locale-source" fixes the "character map file `UTF-8' not found: No such file or directory" error
RUN yum update -y \
&& yum install -y glibc-langpack-en glibc-locale-source \
&& localedef -i en_US -f UTF-8 en_US.UTF-8 \
&& echo "LANG=en_US.UTF-8" > /etc/locale.conf
#FAKECHROOT and FAKEROOT
# Need to install epel-release-latest so both fakechroot and fakeroot can be installed
RUN yum install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
RUN yum install -y fakechroot fakeroot shadow-utils util-linux
# Bake the shared chroot template at build time (as root) so the running
# container never builds it. Writes /opt/chroot/.template/.ready, which makes
# ChrootTemplate.awaitReady() a no-op at startup. Auto-detects Ubuntu/RHEL paths.
RUN bash /opt/semoss-artifacts/artifacts/scripts/build_chroot_template.sh /opt/chroot
# Create a group 'root' with GID 0 if it doesn't exist (it should by default)
RUN groupadd -g 0 root || true
RUN useradd -u 1001 -r -g 0 -d /opt/semosshome -s /bin/bash \
-c "Default Application User" default && \
chown -R 1001:0 /opt/semosshome
USER 1001
WORKDIR /opt/semoss-artifacts/artifacts/scripts
CMD ["bash", "-c", "exec $TOMCAT_HOME/bin/start.sh" ]