Skip to content

Commit b173d11

Browse files
committed
chore: build and publish container image to ghcr.io
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 4fe9424 commit b173d11

6 files changed

Lines changed: 324 additions & 23 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
2+
---
3+
name: Push to registry
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
- 'release/*'
10+
workflow_dispatch:
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v5
26+
27+
- name: Install node 18
28+
uses: actions/setup-node@v6
29+
with:
30+
node-version: 18
31+
cache: npm
32+
33+
- name: Install project modules
34+
run: npm ci
35+
36+
- name: Compile project
37+
run: npm run compile
38+
39+
- name: Get package version
40+
id: package-version
41+
run: |
42+
VERSION=$(node -p "require('./package.json').version")
43+
echo "version=$VERSION" >> $GITHUB_OUTPUT
44+
echo "Package version: $VERSION"
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Log in to Container Registry
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Extract metadata (tags, labels) for Docker
57+
id: meta
58+
uses: docker/metadata-action@v5
59+
with:
60+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
61+
tags: |
62+
type=ref,event=branch
63+
type=ref,event=pr
64+
type=semver,pattern={{version}}
65+
type=semver,pattern={{major}}.{{minor}}
66+
type=semver,pattern={{major}}
67+
type=raw,value=latest,enable={{is_default_branch}}
68+
type=raw,value=${{ steps.package-version.outputs.version }}
69+
70+
- name: Build and push Docker image
71+
uses: docker/build-push-action@v5
72+
with:
73+
context: .
74+
file: ./docker-image/Dockerfiles/Dockerfile
75+
push: true
76+
tags: ${{ steps.meta.outputs.tags }}
77+
labels: ${{ steps.meta.outputs.labels }}
78+
cache-from: type=gha
79+
cache-to: type=gha,mode=max

docker-image/Dockerfiles/Dockerfile

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ FROM registry.access.redhat.com/ubi9/nodejs-20 AS builder
44
# use privilaged user
55
USER root
66

7-
ARG TRUSTIFY_DA_JAVASCRIPT_API_VERSION='0.2.4-ea.12'
8-
97
# install Java
108
RUN curl -kL https://download.oracle.com/java/21/archive/jdk-21.0.1_linux-x64_bin.tar.gz -o /tmp/java-package.tar.gz \
119
&& tar xvzf /tmp/java-package.tar.gz -C /usr/
@@ -19,20 +17,27 @@ RUN curl -kL https://go.dev/dl/go1.21.5.linux-amd64.tar.gz -o /tmp/golang-packag
1917
&& tar xvzf /tmp/golang-package.tar.gz -C /usr/
2018

2119
# install jq JSON formating tool
22-
RUN curl -kL https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux64 -o /usr/bin/jq
20+
RUN curl -kL https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux64 -o /usr/bin/jq
2321

24-
# install Exhort javascript API
25-
RUN npm install --global @trustify-da/trustify-da-javascript-client@${TRUSTIFY_DA_JAVASCRIPT_API_VERSION}
22+
# Copy RHDA script (before changing WORKDIR)
23+
COPY docker-image/scripts/rhda.sh /rhda.sh
2624

27-
# add RHDA script
28-
COPY scripts/rhda.sh /rhda.sh
25+
# Copy project files and install Exhort javascript API locally
26+
WORKDIR /app
27+
COPY package.json package-lock.json ./
28+
COPY dist ./dist
29+
COPY config ./config
30+
RUN npm install --production \
31+
&& mkdir -p /app/node_modules/.bin \
32+
&& ln -s /app/dist/src/cli.js /app/node_modules/.bin/trustify-da-javascript-client
2933

3034
# assign executable permissions to all installed binaries
3135
RUN chmod +x /usr/jdk-21.0.1/bin/java \
3236
&& chmod +x /usr/apache-maven-3.9.6/bin/mvn \
3337
&& chmod +x /usr/go/bin/go \
3438
&& chmod +x /usr/bin/jq \
35-
&& chmod +x /opt/app-root/src/.npm-global/bin/trustify-da-javascript-client \
39+
&& chmod +x /app/dist/src/cli.js \
40+
&& chmod +x /app/node_modules/.bin/trustify-da-javascript-client \
3641
&& chmod +x /rhda.sh
3742

3843
# use default user
@@ -43,8 +48,6 @@ FROM registry.access.redhat.com/ubi9/nodejs-20-minimal
4348

4449
LABEL org.opencontainers.image.source=https://github.com/guacsec/trustify-da-javascript-client
4550

46-
# assign rhda source for exhort tracking purposes
47-
ENV RHDA_SOURCE=''
4851
# contains pip feeze --all data, base64 encoded
4952
ENV TRUSTIFY_DA_PIP_FREEZE=''
5053
# contains pip show data for all packages, base64 encoded
@@ -65,13 +68,13 @@ COPY --from=builder /usr/go/ /usr/go/
6568
ENV GOLANG_HOME=/usr/go
6669

6770
# Update PATH
68-
ENV PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin:$GOLANG_HOME/bin
71+
ENV PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin:$GOLANG_HOME/bin:/app/node_modules/.bin
6972

7073
# Copy jq executable from the builder stage
7174
COPY --from=builder /usr/bin/jq /usr/bin/jq
7275

73-
# Copy trustify-da-javascript-client executable from the builder stage
74-
COPY --from=builder /opt/app-root/src/.npm-global/ /opt/app-root/src/.npm-global/
76+
# Copy trustify-da-javascript-client from the builder stage
77+
COPY --from=builder /app /app
7578

7679
# Copy RHDA executable script from the builder stage
7780
COPY --from=builder /rhda.sh /rhda.sh

docker-image/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# Exhort Javascript API Docker Images
1+
# Trustify Dependency Analytics Javascript Client Container Images
22

3-
These dockerfiles provides all nessesary components to generate images for Red Hat Dependency Analytics (RHDA).
4-
These images can be used as base images to set up the necessary environment and dependencies for running the Red Hat Dependency Analytics.
3+
These dockerfiles provides all nessesary components to generate images for Trustify Dependency Analytics.
4+
These images can be used as base images to set up the necessary environment and dependencies for running the Trustify Dependency Analytics.
55

66
## Prerequisites
77
Before getting started, ensure that you have one of the following prerequisites installed on your system:
88

99
- Docker: [Installation Guide](https://docs.docker.com/get-docker/)
1010
- Podman: [Installation Guide](https://podman.io/docs/installation)
1111

12-
Both Docker and Podman are container runtimes that can be used to build and run the Red Hat Dependency Analytics images. You can choose either Docker or Podman based on your preference and the compatibility with your operating system.
12+
Both Docker and Podman are container runtimes that can be used to build and run the Trustify Dependency Analytics images. You can choose either Docker or Podman based on your preference and the compatibility with your operating system.
1313

14-
## Images generated for Exhort Javascript API
14+
## Images generated for Trustify Dependency Analytics Javascript Client
1515

1616
Ecosystem | Version | IMAGE | TAG |
1717
------------------------------| ------------------------------------------------------------------ | ----------------------------------------------- |-------------------|
18-
Maven, NPM, Golang | mvn 3.9.6, <br>npm 10.2.4, <br>go 1.21.5, <br>python \<any\> | quay.io/ecosystem-appeng/trustify-da-javascript-client | 0.1.1-ea.26 |
18+
Maven, NPM, Golang | mvn 3.9.6, <br>npm 10.2.4, <br>go 1.21.5, <br>python \<any\> | ghcr.io/guacsec/trustify-da-javascript-client | 0.2.4-ea.12 |
1919

2020

2121
## Usage Notes

docker-image/scripts/rhda.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ then
1919

2020
# Print stderr message to console
2121
error_message=$(sed -n '/^Error:/p' error.log)
22-
printf "\n[ERROR] Red Hat Dependency Analytics failed with exit code $exit_code.\n$error_message"
22+
printf "\n[ERROR] Trustify Dependency Analytics failed with exit code $exit_code.\n$error_message"
2323
exit 1
2424
else
2525
# In case of success print report summary into console
26-
printf "\nRed Hat Dependency Analytics Report\n"
26+
printf "\nTrustify Dependency Analytics Report\n"
2727
printf "=%.0s" {1..50}
2828
printf "\n"
2929
printf "Dependencies\n"

integration/scenarios/maven/expected_stack_html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
<th scope="col"># Transitive</th>
197197
<th scope="col">Highest CVSS</th>
198198
<th scope="col">Highest Severity</th>
199-
<th scope="col">Red Hat remediation available</th>
199+
<th scope="col">Remediation available</th>
200200
</tr>
201201
</thead>
202202
<tbody>
@@ -563,7 +563,7 @@
563563
</button>
564564
</div>
565565
<div class="modal-body">
566-
Click either VEX or SBOM to download the corresponding file type. You can also click the package name to view more information in Red Hat's Maven repository.
566+
Click either VEX or SBOM to download the corresponding file type. You can also click the package name to view more information in Trusted Content's Maven repository.
567567
</div>
568568
<div class="modal-footer" style="justify-content: space-around">
569569
<span id="vex"><a href="" target="_blank">VEX</a></span>

0 commit comments

Comments
 (0)