Skip to content

Commit 25f7c51

Browse files
committed
perf: make osi alpine based and moved setup scripts into dockerfile
1 parent 084b66f commit 25f7c51

File tree

4 files changed

+105
-225
lines changed

4 files changed

+105
-225
lines changed
Lines changed: 88 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,107 @@
1-
# Use Ubuntu
2-
FROM ubuntu:latest
1+
# OSI Dockerfile
2+
# Setup OSI environment and setup API service
3+
#
4+
# @author Derek Garcia
5+
6+
# Install tooling
7+
FROM alpine/curl AS spdx_sbom_generator
8+
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
9+
RUN curl -L $SPDX_SBOM_GENERATOR -o /tmp/spdx-sbom-generator.tar.gz && tar -C /tmp -xzf /tmp/spdx-sbom-generator.tar.gz
10+
11+
FROM alpine/curl AS jbom
12+
ENV JBOM=https://github.com/eclipse/jbom/releases/download/v1.2.1/jbom-1.2.1.jar
13+
RUN curl -L $JBOM -o tmp/jbom.jar
14+
15+
FROM alpine/curl AS cyclone_dx_cli
16+
ENV CYCLONEDX_CLI=https://github.com/CycloneDX/cyclonedx-cli/releases/latest/download/cyclonedx-linux-x64
17+
RUN curl -L $CYCLONEDX_CLI -o tmp/cyclonedx-cli
18+
# apt install -y libicu-dev
19+
20+
FROM alpine/curl AS syft
21+
RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /tmp
22+
23+
FROM alpine/curl AS sbomtool
24+
RUN curl -L https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-linux-x64 -o tmp/sbom-tool
25+
26+
FROM alpine/curl AS osi
327

428
# PHP Setup
529
ENV DEBIAN_FRONTEND=noninteractive
630
ENV DEBCONF_NONINTERACTIVE_SEEN=true
731
ENV COMPOSER_ALLOW_SUPERUSER=1
832

933
# Go Setup
10-
ENV PATH=$PATH:/usr/local/go/bin:/root/go/bin
34+
ENV PATH=$PATH:/usr/local/go/bin
35+
36+
# Rust setup
37+
ENV PATH=$PATH:/root/.cargo/bin
1138

1239
# Dotnet tools
1340
ENV PATH=$PATH:/root/.dotnet/tools
1441

15-
# Node.js Setup
16-
ENV NVM_DIR=/root/.nvm
17-
1842
# Bound Directories
1943
ENV CODE_IN=/bound_dir/code
2044
ENV SBOM_OUT=/bound_dir/sboms
2145

22-
# Copy startup scripts
23-
COPY scripts/ /usr/local/bin/
24-
# Copy Flask webserver scripts
25-
COPY server/ /server
46+
#
47+
# Setup the OSI enviroment
48+
#
2649

27-
# Run setup script
28-
RUN /bin/bash -c setup.sh
50+
# Install languages
51+
RUN apk update && apk add \
52+
python3 \
53+
openjdk21-jdk \
54+
dotnet6-sdk \
55+
nodejs
56+
# go
57+
COPY --from=golang:alpine /usr/local/go/ /usr/local/go/
58+
# rust
59+
RUN apk add \
60+
build-base \
61+
libffi-dev \
62+
openssl-dev
63+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
2964

30-
# Cleanup
31-
RUN rm /usr/local/bin/setup.sh
65+
# Install Package managers
66+
RUN apk add \
67+
py3-pip \
68+
maven \
69+
gradle \
70+
composer \
71+
npm
72+
# conan
73+
RUN pip install --break-system-packages conan
74+
75+
# Install tools using package managers
76+
RUN pip install --break-system-packages flask jake cyclonedx-conan cyclonedx-bom scanoss sbom4python sbom4rust sbom4files
77+
RUN npm install -g retire bower cdx-bower-bom @cyclonedx/cdxgen@8.6.0
78+
RUN go install github.com/ozonru/cyclonedx-go/cmd/cyclonedx-go@latest
79+
RUN go install github.com/mattermost/gobom/cmd/gobom@latest
80+
RUN dotnet tool install --global covenant
81+
RUN cargo install -- cargo-cyclonedx
82+
RUN composer global config --no-plugins allow-plugins.cyclonedx/cyclonedx-php-composer true
83+
RUN composer \
84+
--ignore-platform-req=ext-xmlwriter \
85+
--ignore-platform-req=ext-dom \
86+
global require cyclonedx/cyclonedx-php-composer
87+
88+
# Copy binaries
89+
COPY --from=spdx_sbom_generator --chmod=755 /tmp/spdx-sbom-generator /usr/local/bin/
90+
COPY --from=jbom --chmod=755 tmp/jbom.jar /usr/local/bin/
91+
COPY --from=cyclone_dx_cli --chmod=755 tmp/cyclonedx-cli /usr/local/bin/
92+
COPY --from=syft --chmod=755 tmp/syft /usr/local/bin/
93+
COPY --from=sbomtool --chmod=755 tmp/sbom-tool /usr/local/bin/
3294

33-
RUN ["chmod", "+x", "/usr/local/bin/runner.sh"]
95+
# Verify installation
96+
COPY --chmod=755 scripts/ /usr/local/bin/
97+
RUN . validate.sh
98+
99+
# Setup flask api server
100+
WORKDIR /server
101+
COPY server/ .
102+
RUN pip install --break-system-packages -r requirements.txt
103+
104+
# Cleanup
105+
RUN rm -rf /var/cache/apk/* /tmp/*
34106

35-
ENTRYPOINT ["usr/local/bin/runner.sh"]
107+
CMD ["runner.sh"]

core/src/main/java/org/svip/generation/osi/docker/scripts/runner.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/ash
22

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

1010
# Activate env
1111
. "$HOME"/.cargo/env
12-
. "$NVM_DIR"/nvm.sh
1312

1413
# Check before running
1514
. validate.sh
1615

1716
# Launch server
1817
echo "Launching Server"
19-
cd /server || exit 1
2018
python3 /server/OSIServer.py
2119
}
2220

core/src/main/java/org/svip/generation/osi/docker/scripts/setup.sh

Lines changed: 0 additions & 184 deletions
This file was deleted.

0 commit comments

Comments
 (0)