-
-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1303 from k3rnelpan1c-dev/package/temurin
packaging: Overhaul Containerfile and use Temurin JRE
- Loading branch information
Showing
3 changed files
with
90 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "maven" | ||
directory: "/" | ||
- package-ecosystem: maven | ||
directory: / | ||
schedule: | ||
interval: "daily" | ||
interval: daily | ||
- package-ecosystem: docker | ||
directory: /src/main/docker | ||
schedule: | ||
interval: weekly | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: weekly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,70 @@ | ||
FROM debian:stable-slim | ||
LABEL maintainer="steve.springett@owasp.org" | ||
LABEL vendor="OWASP" | ||
FROM eclipse-temurin:17.0.2_8-jre-focal AS jre-build | ||
|
||
FROM debian:bullseye-20220125-slim | ||
|
||
# Arguments that can be passed at build time | ||
# Directory names must end with / to avoid errors when ADDing and COPYing | ||
ARG COMMIT_SHA | ||
ARG APP_VERSION | ||
ARG APP_DIR=/opt/owasp/dependency-track/ | ||
ARG DATA_DIR=/data/ | ||
ARG USERNAME=dtrack | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
ARG WAR_FILENAME=dependency-track-apiserver.jar | ||
|
||
ENV TZ=Etc/UTC \ | ||
# Dependency-Track's default logging level | ||
LOGGING_LEVEL=INFO \ | ||
# Environment variables that can be passed at runtime | ||
JAVA_OPTIONS="-XX:+UseParallelGC -XX:MaxRAMPercentage=90.0" \ | ||
# The web context defaults to the root. To override, supply an alternative context which starts with a / but does not end with one | ||
# Example: /dtrack | ||
CONTEXT="/" \ | ||
# Injects the build-time ARG "WAR_FILENAME" as an environment variable that can be used in the CMD. | ||
WAR_FILENAME=${WAR_FILENAME} \ | ||
# Set JAVA_HOME for the copied over JRE | ||
JAVA_HOME=/opt/java/openjdk \ | ||
PATH="/opt/java/openjdk/bin:${PATH}" \ | ||
LANG=C.UTF-8 | ||
|
||
COPY --from=jre-build /opt/java/openjdk $JAVA_HOME | ||
|
||
# Copy the compiled WAR to the application directory created above | ||
# Automatically creates the $APP_DIR directory | ||
COPY ./target/${WAR_FILENAME} ${APP_DIR} | ||
|
||
# Create the directory where Dependency-Track will store its data (${DATA_DIR}) and the external library directory (${EXTLIB_DIR}) | ||
# Create a user and assign home directory to a ${DATA_DIR} | ||
# Ensure UID 1000 & GID 1000 own all the needed directories | ||
RUN mkdir -p -m 770 ${DATA_DIR} \ | ||
&& useradd --home-dir ${DATA_DIR} --uid 1000 ${USERNAME} \ | ||
&& chown -R ${USERNAME}:${USERNAME} ${DATA_DIR} \ | ||
# install dependencies necessary in order to install Azul OpenJDK | ||
&& apt-get -q update && apt-get -y upgrade \ | ||
&& apt-get -yq install gnupg curl \ | ||
# add Azul's public key | ||
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9 \ | ||
# download and install the package that adds | ||
# the Azul APT repository to the list of sources | ||
&& curl -O https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb \ | ||
# install the package | ||
&& apt-get install ./zulu-repo_1.0.0-3_all.deb \ | ||
# update the package sources | ||
&& apt-get update \ | ||
# install Azul Zulu JRE | ||
&& apt-get -y install zulu17-ca-jre-headless | ||
|
||
# Copy the compiled WAR to the application directory created above | ||
# Automatically creates the $APP_DIR directory | ||
COPY --chown=1000 ./target/${WAR_FILENAME} ${APP_DIR} | ||
&& addgroup --system --gid ${GID} dtrack || true \ | ||
&& adduser --system --disabled-login --ingroup dtrack --no-create-home --home ${DATA_DIR} --gecos "dtrack user" --shell /bin/false --uid ${UID} dtrack || true \ | ||
&& chown -R dtrack:0 ${DATA_DIR} ${APP_DIR} \ | ||
&& chmod -R g=u ${DATA_DIR} ${APP_DIR} | ||
|
||
# Specify the user to run as (in numeric format for compatibility with Kubernetes/OpenShift's SCC) | ||
USER 1000 | ||
USER ${UID} | ||
|
||
# Specify the container working directory | ||
WORKDIR ${APP_DIR} | ||
|
||
# Launch Dependency-Track | ||
CMD java $JAVA_OPTIONS -DdependencyTrack.logging.level=$LOGGING_LEVEL -jar ${WAR_FILENAME} -context ${CONTEXT} | ||
CMD java ${JAVA_OPTIONS} -DdependencyTrack.logging.level=${LOGGING_LEVEL} -jar ${WAR_FILENAME} -context ${CONTEXT} | ||
|
||
# Specify which port Dependency-Track listens on | ||
EXPOSE 8080 | ||
|
||
# Dependency-Track's default logging level | ||
ENV LOGGING_LEVEL=INFO | ||
|
||
# Environment variables that can be passed at runtime | ||
ENV JAVA_OPTIONS="-XX:+UseParallelGC -XX:MaxRAMPercentage=90.0" | ||
|
||
# The web context defaults to the root. To override, supply an alternative context which starts with a / but does not end with one | ||
# Example: /dtrack | ||
ENV CONTEXT="" | ||
|
||
# Injects the build-time ARG "WAR_FILENAME" as an environment variable that can be used in the CMD. | ||
ENV WAR_FILENAME ${WAR_FILENAME} | ||
|
||
# Add a healthcheck using the Dependency-Track version API | ||
HEALTHCHECK --interval=5m --timeout=3s CMD wget --proxy off -q -O /dev/null http://127.0.0.1:8080${CONTEXT}/api/version || exit 1 | ||
HEALTHCHECK --interval=5m --timeout=3s CMD wget --proxy off -q -O /dev/null http://127.0.0.1:8080${CONTEXT}api/version || exit 1 | ||
|
||
# metadata labels | ||
LABEL \ | ||
org.opencontainers.image.vendor="OWASP" \ | ||
org.opencontainers.image.title="Official Dependency-Track Container image" \ | ||
org.opencontainers.image.description="Dependency-Track is an intelligent Component Analysis platform" \ | ||
org.opencontainers.image.version="${APP_VERSION}" \ | ||
org.opencontainers.image.url="https://dependencytrack.org/" \ | ||
org.opencontainers.image.source="https://github.com/DependencyTrack/dependency-track" \ | ||
org.opencontainers.image.revision="${COMMIT_SHA}" \ | ||
org.opencontainers.image.licenses="Apache-2.0" \ | ||
maintainer="steve.springett@owasp.org" |