Skip to content

Commit

Permalink
Merge branch 'bugfix/osi' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dlg1206 committed Aug 28, 2024
2 parents 9efb3f7 + 0f5fc2b commit 906efac
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 233 deletions.
111 changes: 89 additions & 22 deletions core/src/main/java/org/svip/generation/osi/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,102 @@
# Use Ubuntu
FROM ubuntu:latest
# OSI Dockerfile
# Setup OSI environment and setup API service
#
# @author Derek Garcia

# Install tooling
FROM alpine/curl AS spdx_sbom_generator
ENV SPDX_SBOM_GENERATOR=https://github.com/opensbom-generator/spdx-sbom-generator/releases/download/v0.0.15/spdx-sbom-generator-v0.0.15-linux-amd64.tar.gz
RUN curl -L $SPDX_SBOM_GENERATOR -o /tmp/spdx-sbom-generator.tar.gz && tar -C /tmp -xzf /tmp/spdx-sbom-generator.tar.gz

FROM alpine/curl AS jbom
ENV JBOM=https://github.com/eclipse/jbom/releases/download/v1.2.1/jbom-1.2.1.jar
RUN curl -L $JBOM -o tmp/jbom.jar

FROM alpine/curl AS cyclone_dx_cli
ENV CYCLONEDX_CLI=https://github.com/CycloneDX/cyclonedx-cli/releases/latest/download/cyclonedx-linux-x64
RUN curl -L $CYCLONEDX_CLI -o tmp/cyclonedx-cli
# apt install -y libicu-dev

FROM alpine/curl AS syft
RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /tmp

FROM alpine/curl AS osi

# PHP Setup
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
ENV COMPOSER_ALLOW_SUPERUSER=1

# Go Setup
ENV PATH $PATH:/usr/local/go/bin:/root/go/bin
ENV PATH=$PATH:/usr/local/go/bin

# Dotnet tools
ENV PATH $PATH:/root/.dotnet/tools
# Rust setup
ENV PATH=$PATH:/root/.cargo/bin

# Node.js Setup
ENV NVM_DIR /root/.nvm
# Dotnet tools
ENV PATH=$PATH:/root/.dotnet/tools

# Bound Directories
ENV CODE_IN /bound_dir/code
ENV SBOM_OUT /bound_dir/sboms
ENV CODE_IN=/bound_dir/code
ENV SBOM_OUT=/bound_dir/sboms

# Copy startup scripts
COPY scripts/ /usr/local/bin/
# Copy Flask webserver scripts
COPY server/ /server
#
# Setup the OSI enviroment
#

# Run setup script
RUN /bin/bash -c setup.sh
# Install languages
RUN apk update && apk add \
python3 \
openjdk21-jdk \
dotnet6-sdk \
nodejs
# go
COPY --from=golang:alpine /usr/local/go/ /usr/local/go/
# rust
RUN apk add \
build-base \
libffi-dev \
openssl-dev
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Cleanup
RUN rm /usr/local/bin/setup.sh
# Install Package managers
RUN apk add \
py3-pip \
maven \
gradle \
composer \
npm
# conan
RUN pip install --break-system-packages conan

# Install tools using package managers
RUN pip install --break-system-packages flask jake cyclonedx-conan cyclonedx-bom scanoss sbom4python sbom4rust sbom4files
RUN npm install -g retire bower cdx-bower-bom @cyclonedx/[email protected]
RUN go install github.com/ozonru/cyclonedx-go/cmd/cyclonedx-go@latest
RUN go install github.com/mattermost/gobom/cmd/gobom@latest
RUN dotnet tool install --global covenant
RUN dotnet tool install --global Microsoft.Sbom.DotNetTool
RUN cargo install -- cargo-cyclonedx
RUN composer global config --no-plugins allow-plugins.cyclonedx/cyclonedx-php-composer true
RUN composer \
--ignore-platform-req=ext-xmlwriter \
--ignore-platform-req=ext-dom \
global require cyclonedx/cyclonedx-php-composer

RUN ["chmod", "+x", "/usr/local/bin/runner.sh"]
# Copy binaries
# Unavailable in alpine
#COPY --from=spdx_sbom_generator --chmod=755 /tmp/spdx-sbom-generator /usr/local/bin/
COPY --from=jbom --chmod=755 tmp/jbom.jar /usr/local/bin/
COPY --from=cyclone_dx_cli --chmod=755 tmp/cyclonedx-cli /usr/local/bin/
COPY --from=syft --chmod=755 tmp/syft /usr/local/bin/

# Setup flask api server
COPY --chmod=755 scripts/ /usr/local/bin/
WORKDIR /server
COPY server/ .
RUN pip install --break-system-packages -r requirements.txt

# Cleanup
RUN rm -rf /var/cache/apk/* /tmp/*

ENTRYPOINT ["usr/local/bin/runner.sh"]
CMD ["runner.sh"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/ash

# File: runner.sh
# Launch the Flask API server to host OSI
Expand All @@ -9,14 +9,12 @@ main(){

# Activate env
. "$HOME"/.cargo/env
. "$NVM_DIR"/nvm.sh

# Check before running
. validate.sh

# Launch server
echo "Launching Server"
cd /server || exit 1
python3 /server/OSIServer.py
}

Expand Down
184 changes: 0 additions & 184 deletions core/src/main/java/org/svip/generation/osi/docker/scripts/setup.sh

This file was deleted.

Loading

0 comments on commit 906efac

Please sign in to comment.