Skip to content

Commit

Permalink
Merge pull request #59 from RHEcosystemAppEng/feat/image-go-support
Browse files Browse the repository at this point in the history
feat: add Golang support to exhort-javascript-api image.
  • Loading branch information
zvigrinberg authored Oct 8, 2023
2 parents 20ad905 + bc50f60 commit f033d55
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
IMAGE_REGISTRY_USER: ${{ secrets.IMAGE_REGISTRY_USER }}
IMAGE_REGISTRY_PASSWORD: ${{ secrets.IMAGE_REGISTRY_PASSWORD }}
DOCKERFILE_PATH: ./docker-image/Dockerfiles/Dockerfile.alpha
GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN: ${{ secrets.GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN }}
PACKAGE_REGISTRY_ACCESS_TOKEN: ${{ secrets.PACKAGE_REGISTRY_ACCESS_TOKEN }}

on:
workflow_dispatch:
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
dockerfiles: |
${{ env.DOCKERFILE_PATH }}
build-args: |
GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN=${{ env.GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN }}
PACKAGE_REGISTRY_ACCESS_TOKEN=${{ env.PACKAGE_REGISTRY_ACCESS_TOKEN }}
context: docker-image

- name: Push Image To Registry
Expand Down
37 changes: 24 additions & 13 deletions docker-image/Dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM registry.access.redhat.com/ubi9/nodejs-18 as builder
USER root

# assign token for reading packages from github package registry
ARG GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN=''
ARG PACKAGE_REGISTRY_ACCESS_TOKEN=''

# install Java
RUN curl -kL https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.tar.gz -o /tmp/java-package.tar.gz \
Expand All @@ -15,45 +15,53 @@ RUN curl -kL https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.tar
RUN curl -kL https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz -o /tmp/maven-package.tar.gz \
&& tar xvzf /tmp/maven-package.tar.gz -C /usr/

# install go package manager
RUN curl -kL https://go.dev/dl/go1.20.6.linux-amd64.tar.gz -o /tmp/go-package.tar.gz \
&& tar xvzf /tmp/go-package.tar.gz -C /usr/
# install golang package manager
RUN curl -kL https://go.dev/dl/go1.21.1.linux-amd64.tar.gz -o /tmp/golang-package.tar.gz \
&& tar xvzf /tmp/golang-package.tar.gz -C /usr/

# install python package manager (pip)
RUN python3 -m ensurepip --upgrade

# install jq JSON formating tool
RUN curl -kL https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -o /usr/bin/jq

# install linux utils Package to enable UUID generation
RUN yum install util-linux

# copy the .npmrc file
COPY configs/.npmrc .
# replace placeholder with the actual environment variable
RUN sed -i "s/__GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN__/${GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN}/g" ./.npmrc
RUN sed -i "s/__PACKAGE_REGISTRY_ACCESS_TOKEN__/${PACKAGE_REGISTRY_ACCESS_TOKEN}/g" ./.npmrc
# install Exhort javascript API
RUN npm install --global @RHEcosystemAppEng/exhort-javascript-api

# add exhort script
COPY scripts/exhort.sh /
# add RHDA script
COPY scripts/rhda.sh /

# assign executable permissions to all installed binaries
RUN chmod +x /usr/jdk-20.0.2/bin/java \
&& chmod +x /usr/apache-maven-3.9.4/bin/mvn \
&& chmod +x /usr/go/bin/go \
&& chmod +x /usr/local/bin/pip3 \
&& chmod +x /usr/bin/jq \
&& chmod +x /usr/bin/uuidgen \
&& chmod +x /opt/app-root/src/.npm-global/bin/exhort-javascript-api \
&& chmod +x /exhort.sh
&& chmod +x /rhda.sh

# use default user
USER default

#second stage
# second stage
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal

LABEL org.opencontainers.image.source https://github.com/RHEcosystemAppEng/exhort-javascript-api

# assign token for exhort authentication with Snyk provider
ENV EXHORT_SNYK_TOKEN=''
# assign rhda token for rhda user authentication with exhort
ENV RHDA_TOKEN=''
# assign rhda source for exhort tracking purposes
ENV RHDA_SOURCE=''

# Copy java executable from the builder stage
COPY --from=builder /usr/jdk-20.0.2/ /usr/jdk-20.0.2/
Expand All @@ -65,10 +73,10 @@ ENV MAVEN_HOME=/usr/apache-maven-3.9.4

# Copy golang executable from the builder stage
COPY --from=builder /usr/go/ /usr/go/
ENV GO_HOME=/usr/go
ENV GOLANG_HOME=/usr/go

# Update PATH
ENV PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin:$GO_HOME/bin
ENV PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin:$GOLANG_HOME/bin

# Copy python executable from the builder stage
COPY --from=builder /usr/bin/python3 /usr/bin/python3
Expand All @@ -84,8 +92,11 @@ RUN ln -s /usr/bin/python3 /usr/bin/python \
# Copy jq executable from the builder stage
COPY --from=builder /usr/bin/jq /usr/bin/jq

# Copy uuidgen executable from the builder stage
COPY --from=builder /usr/bin/uuidgen /usr/bin/uuidgen

# Copy exhort-javascript-api executable from the builder stage
COPY --from=builder /opt/app-root/src/.npm-global/ /opt/app-root/src/.npm-global/

# Copy exhort executable script from the builder stage
COPY --from=builder /exhort.sh /exhort.sh
# Copy RHDA executable script from the builder stage
COPY --from=builder /rhda.sh /rhda.sh
38 changes: 29 additions & 9 deletions docker-image/Dockerfiles/Dockerfile.alpha
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM registry.access.redhat.com/ubi9/nodejs-18 as builder
USER root

# assign token for reading packages from github package registry
ARG GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN=''
ARG PACKAGE_REGISTRY_ACCESS_TOKEN=''

# install Java
RUN curl -kL https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.tar.gz -o /tmp/java-package.tar.gz \
Expand All @@ -15,36 +15,49 @@ RUN curl -kL https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.tar
RUN curl -kL https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz -o /tmp/maven-package.tar.gz \
&& tar xvzf /tmp/maven-package.tar.gz -C /usr/

# install golang package manager
RUN curl -kL https://go.dev/dl/go1.21.1.linux-amd64.tar.gz -o /tmp/golang-package.tar.gz \
&& tar xvzf /tmp/golang-package.tar.gz -C /usr/

# install jq JSON formating tool
RUN curl -kL https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -o /usr/bin/jq

# install linux utils Package to enable UUID generation
RUN yum install util-linux

# copy the .npmrc file
COPY configs/.npmrc .
# replace placeholder with the actual environment variable
RUN sed -i "s/__GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN__/${GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN}/g" ./.npmrc
RUN sed -i "s/__PACKAGE_REGISTRY_ACCESS_TOKEN__/${PACKAGE_REGISTRY_ACCESS_TOKEN}/g" ./.npmrc
# install Exhort javascript API
RUN npm install --global @RHEcosystemAppEng/exhort-javascript-api

# add exhort script
COPY scripts/exhort.sh /
# add RHDA script
COPY scripts/rhda.sh /

# assign executable permissions to all installed binaries
RUN chmod +x /usr/jdk-20.0.2/bin/java \
&& chmod +x /usr/apache-maven-3.9.4/bin/mvn \
&& chmod +x /usr/go/bin/go \
&& chmod +x /usr/bin/jq \
&& chmod +x /usr/bin/uuidgen \
&& chmod +x /opt/app-root/src/.npm-global/bin/exhort-javascript-api \
&& chmod +x /exhort.sh
&& chmod +x /rhda.sh

# use default user
USER default

#second stage
# second stage
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal

LABEL org.opencontainers.image.source https://github.com/RHEcosystemAppEng/exhort-javascript-api

# assign token for exhort authentication with Snyk provider
ENV EXHORT_SNYK_TOKEN=''
# assign rhda token for rhda user authentication with exhort
ENV RHDA_TOKEN=''
# assign rhda source for exhort tracking purposes
ENV RHDA_SOURCE=''

# Copy java executable from the builder stage
COPY --from=builder /usr/jdk-20.0.2/ /usr/jdk-20.0.2/
Expand All @@ -54,14 +67,21 @@ ENV JAVA_HOME=/usr/jdk-20.0.2
COPY --from=builder /usr/apache-maven-3.9.4/ /usr/apache-maven-3.9.4/
ENV MAVEN_HOME=/usr/apache-maven-3.9.4

# Copy golang executable from the builder stage
COPY --from=builder /usr/go/ /usr/go/
ENV GOLANG_HOME=/usr/go

# Update PATH
ENV PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin
ENV PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin:$GOLANG_HOME/bin

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

# Copy uuidgen executable from the builder stage
COPY --from=builder /usr/bin/uuidgen /usr/bin/uuidgen

# Copy exhort-javascript-api executable from the builder stage
COPY --from=builder /opt/app-root/src/.npm-global/ /opt/app-root/src/.npm-global/

# Copy exhort executable script from the builder stage
COPY --from=builder /exhort.sh /exhort.sh
# Copy RHDA executable script from the builder stage
COPY --from=builder /rhda.sh /rhda.sh
7 changes: 4 additions & 3 deletions docker-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Both Docker and Podman are container runtimes that can be used to build and run

## Images generated for Exhort Javascript API

Ecosystem | Version | IMAGE | TAG |
------------- | ------------------------------------------------------------------ | ----------------------------------------------- |-------------------|
Maven & NPM | maven 3.9.4, <br>npm 9.5.0 | quay.io/ecosystem-appeng/exhort-javascript-api | 1.0-alpha |
Ecosystem | Version | IMAGE | TAG |
----------------------| ------------------------------------------------------------------ | ----------------------------------------------- |-------------------|
Maven & NPM | mvn 3.9.4, <br>npm 9.5.0 | quay.io/ecosystem-appeng/exhort-javascript-api | 0.7.0-alpha |
Maven, NPM & Golang | mvn 3.9.4, <br>npm 9.5.0, <br>go 1.21.1 | quay.io/ecosystem-appeng/exhort-javascript-api | 0.7.3-alpha |
2 changes: 1 addition & 1 deletion docker-image/configs/.npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
//npm.pkg.github.com/:_authToken=__GITHUB_PACKAGE_REGISTRY_ACCESS_TOKEN__
//npm.pkg.github.com/:_authToken=__PACKAGE_REGISTRY_ACCESS_TOKEN__
@RHEcosystemAppEng:registry=https://npm.pkg.github.com
File renamed without changes.

0 comments on commit f033d55

Please sign in to comment.