Skip to content

Add alpine go 1.21 image #1920

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ jobs:
distro: debian
runner: macos-hosted

- lang: golang121
distro: alpine

- lang: golang123
distro: alpine

Expand Down
3 changes: 2 additions & 1 deletion ci/images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Below table summarizes all available container image versions. These images incl
| Ruby | 2.6.10 | ghcr.io/cyclonedx/cdxgen-debian-ruby26:v11 | Supports automatic Ruby installation for 2.6.x. Example: Pass `-t ruby2.6.1` to install Ruby 2.6.1. |
| Ruby | 3.4.4 | ghcr.io/cyclonedx/cdxgen-alpine-ruby344:v11 | Ruby 3.4.4 |
| Ruby | 1.8.x | ghcr.io/cyclonedx/debian-ruby18:master | Base image for `bundle install` only. No cdxgen equivalent with Ruby 1.8.x. `--deep` mode and research profile unsupported. |
| Swift | 6.0.x | ghcr.io/cyclonedx/cdxgen-debian-swift:v11 | Swift 6 |
| Swift | 6.0.x | ghcr.io/cyclonedx/cdxgen-debian-swift:v11 | Swift 6
| golang | 1.21 | ghcr.io/cyclonedx/cdxgen-alpine-golang121:v11 | Golang 1.21
| golang | 1.23 | ghcr.io/cyclonedx/cdxgen-debian-golang123:v11, ghcr.io/cyclonedx/cdxgen-alpine-golang123:v11 | Golang 1.23 |
| golang | 1.24 | ghcr.io/cyclonedx/cdxgen-debian-golang124:v11, ghcr.io/cyclonedx/cdxgen-debian-golang:v11, ghcr.io/cyclonedx/cdxgen-alpine-golang124:v11, ghcr.io/cyclonedx/cdxgen-alpine-golang:v11 | Golang 1.24 |
| Rust | 1 | ghcr.io/cyclonedx/cdxgen-debian-rust, ghcr.io/cyclonedx/cdxgen-debian-rust1:v11 | This is a rolling version that will get the latest released version. Currently, 1.87. |
Expand Down
42 changes: 42 additions & 0 deletions ci/images/alpine/Dockerfile.golang121
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Base-image
FROM golang:1.21-alpine AS base
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this argument could be templatised with a build-arg and we execute the same Dockerfile a few times with different Go versions? @malice00 any thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably can. Might need some tweaking in the workflows & actions and add another parameter or something like that. @bandhan-majumder you want to give it a try, or do you want me to look at it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I may need some time as my exams are going on. If there is no urgency of this, I can take a look after some days. Also, the argument will have to templatised in two places I think, in the base image and in the label org.opencontainers.docker.cmd. Please correct me if I am wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about urgency on this... Did @prabhu say anything when he gave you the assignment?
@prabhu we can always merge as-is and open a new issue on the templating if you need this image asap?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not urgent at all.


ENV PATH=${PATH}:/usr/local/bin

RUN apk update && apk add --no-cache \
nodejs \
npm \
&& npm install -g corepack \
&& node -v \
&& npm -v \
&& rm -rf /var/cache/apk/*

# cdxgen-image
FROM base AS cdxgen

LABEL maintainer="CycloneDX" \
org.opencontainers.image.authors="Team AppThreat <[email protected]>" \
org.opencontainers.image.source="https://github.com/CycloneDX/cdxgen" \
org.opencontainers.image.url="https://github.com/CycloneDX/cdxgen" \
org.opencontainers.image.version="rolling" \
org.opencontainers.image.vendor="CycloneDX" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="cdxgen" \
org.opencontainers.image.description="Rolling image with cdxgen SBOM generator for go apps" \
org.opencontainers.docker.cmd="docker run --rm -v /tmp:/tmp -p 9090:9090 -v $(pwd):/app:rw -t ghcr.io/cyclonedx/cdxgen-alpine-golang121:v11 -r /app --server"

ENV CDXGEN_IN_CONTAINER=true \
NODE_COMPILE_CACHE="/opt/cdxgen-node-cache" \
PATH=${PATH}:/usr/local/bin:/opt/cdxgen/node_modules/.bin

COPY . /opt/cdxgen

RUN cd /opt/cdxgen && corepack enable && corepack pnpm install --config.strict-dep-builds=true --prod --no-optional --package-import-method copy --frozen-lockfile && corepack pnpm cache delete \
&& npm uninstall -g corepack \
&& apk del npm \
&& mkdir -p ${NODE_COMPILE_CACHE} \
&& node /opt/cdxgen/bin/cdxgen.js --help \
&& rm -rf /root/.cache/node \
&& chmod a-w -R /opt
WORKDIR /app
ENTRYPOINT ["node", "/opt/cdxgen/bin/cdxgen.js"]
Loading