-
-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
packaging: Overhaul Containerfile and use Temurin JRE #1303
Merged
stevespringett
merged 3 commits into
DependencyTrack:master
from
k3rnelpan1c-dev:package/temurin
Feb 15, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JQ and Docker are both already installed in a recent version in the GitHub Actions Virtual environment and since you don't seem to use
trivy
here, and it having an official action otherwise, I cleaned up this overhead