Skip to content
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

Mac os support #126

Closed
wants to merge 12 commits into from
50 changes: 49 additions & 1 deletion .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,52 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: |
fosslight/fosslight_scanner:latest
fosslight/fosslight_scanner:${{ github.event.release.tag_name }}
fosslight/fosslight_scanner:${{ github.event.release.tag_name }}

create-windows-executable:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install dependencies
run: |
pip install pyinstaller

- name: Create executable
run: pyinstaller --onefile fosslight_wrapper.py

- name: Upload executable to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/fosslight_wrapper.exe
asset_name: fosslight_wrapper.exe
asset_content_type: application/vnd.microsoft.portable-executable

create-macos-command-file:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create .command file
run: |
chmod +x fosslight_wrapper_mac.command

- name: Upload .command file to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./fosslight_wrapper_mac.command
asset_name: fosslight_wrapper_mac.command
asset_content_type: application/x-sh
69 changes: 60 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,74 @@
FROM python:3.8-slim-buster

COPY . /app
WORKDIR /app
WORKDIR /app

RUN ln -sf /bin/bash /bin/sh && \
# Install necessary packages including nodejs, npm, and default-jdk
RUN ln -sf /bin/bash /bin/sh && \
apt-get update && \
apt-get install --no-install-recommends -y \
apt-get install --no-install-recommends -y \
build-essential \
python3 python3-distutils python3-pip python3-dev python3-magic \
libxml2-dev \
libxslt1-dev \
libhdf5-dev \
bzip2 xz-utils zlib1g libpopt0 && \
bzip2 xz-utils zlib1g libpopt0 \
curl \
default-jdk && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN pip3 install --upgrade pip && \
pip3 install . && \
pip3 install dparse && \
rm -rf ~/.cache/pip /root/.cache/pipe
# Set JAVA_HOME dynamically
RUN echo "export JAVA_HOME=\$(dirname \$(dirname \$(readlink -f \$(which java))))" >> /etc/profile && \
echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile

ENTRYPOINT ["/usr/local/bin/fosslight"]
# Install license-checker globally
RUN npm install -g license-checker

RUN pip3 install --upgrade pip && \
pip3 install fosslight_util && \
pip3 install python-magic && \
pip3 install dparse

RUN pip3 install fosslight_source --no-deps && \
pip3 show fosslight_source | grep "Requires:" | sed 's/Requires://' | tr ',' '\n' | grep -v "typecode-libmagic" > /tmp/fosslight_source_deps.txt && \
pip3 install -r /tmp/fosslight_source_deps.txt && \
rm /tmp/fosslight_source_deps.txt

COPY requirements.txt /tmp/requirements.txt
RUN grep -vE "fosslight[-_]source" /tmp/requirements.txt > /tmp/custom_requirements.txt && \
pip3 install -r /tmp/custom_requirements.txt && \
rm /tmp/requirements.txt /tmp/custom_requirements.txt

COPY . /fosslight_scanner
WORKDIR /fosslight_scanner
RUN pip3 install . --no-deps && \
rm -rf ~/.cache/pip /root/.cache/pip

# Add /usr/local/bin to the PATH
ENV PATH="/usr/local/bin:${PATH}"

VOLUME /src
WORKDIR /src

# Create and set up the entrypoint script
RUN echo '#!/bin/bash' > /entrypoint.sh && \
echo 'source /etc/profile' >> /entrypoint.sh && \
echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))' >> /entrypoint.sh && \
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /entrypoint.sh && \
echo 'if command -v "$1" > /dev/null 2>&1; then' >> /entrypoint.sh && \
echo ' exec "$@"' >> /entrypoint.sh && \
echo 'else' >> /entrypoint.sh && \
echo ' exec fosslight "$@"' >> /entrypoint.sh && \
echo 'fi' >> /entrypoint.sh && \
chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

CMD ["-h"]

# Clean up the build
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/*
16 changes: 16 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Copyright (c) 2022 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0

# Set JAVA_HOME dynamically
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
export PATH=$JAVA_HOME/bin:$PATH

# Check if the first argument is a command, if so execute it
if command -v "$1" > /dev/null 2>&1; then
exec "$@"
else
# If not a command, run fosslight with arguments
exec fosslight "$@"
fi
Loading
Loading