Skip to content
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
25 changes: 16 additions & 9 deletions workers/analyzer/docker/Analyzer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
ARG PYENV_GIT_TAG

ENV PYENV_ROOT=/opt/python
ENV PATH=$PATH:$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PYENV_ROOT/conan2/bin
ENV PATH=$PATH:$PYENV_ROOT/shims:$PYENV_ROOT/bin
RUN curl -kSs https://pyenv.run | bash \
&& pyenv install -v $PYTHON_VERSION \
&& pyenv global $PYTHON_VERSION
Expand All @@ -182,16 +182,23 @@
wheel \
&& pip install --no-cache-dir -U \
Mercurial \
conan=="$CONAN_VERSION" \
pipenv=="$PYTHON_PIPENV_VERSION" \
poetry=="$PYTHON_POETRY_VERSION" \
python-inspector=="$PYTHON_INSPECTOR_VERSION"
RUN mkdir /tmp/conan2 && cd /tmp/conan2 \
&& wget https://github.com/conan-io/conan/releases/download/$CONAN2_VERSION/conan-$CONAN2_VERSION-linux-x86_64.tgz \
&& tar -xvf conan-$CONAN2_VERSION-linux-x86_64.tgz\
# Rename the Conan 2 executable to "conan2" to be able to call both Conan version from the package manager.
&& mkdir $PYENV_ROOT/conan2 && mv /tmp/conan2/bin $PYENV_ROOT/conan2/ \
&& mv $PYENV_ROOT/conan2/bin/conan $PYENV_ROOT/conan2/bin/conan2

# Create conan environments
COPY scripts/setup_conan.sh ${PYENV_ROOT}/bin/conan
RUN eval "$(pyenv init - bash)" \
&& eval "$(pyenv virtualenv-init -)" \
&& pyenv virtualenv conan \
&& pyenv activate conan \
&& pip install conan==${CONAN_VERSION} \
&& pyenv deactivate \
&& pyenv virtualenv conan2 \
&& pyenv activate conan2 \
&& pip install conan==${CONAN2_VERSION} \
&& pyenv deactivate \
&& sudo chmod +x ${PYENV_ROOT}/bin/conan

FROM scratch AS python
COPY --from=pythonbuild /opt/python /opt/python
Expand All @@ -216,7 +223,7 @@
&& corepack enable

FROM scratch AS node
COPY --from=nodebuild $NVM_DIR $NVM_DIR

Check warning on line 226 in workers/analyzer/docker/Analyzer.Dockerfile

View workflow job for this annotation

GitHub Actions / Build analyzer-worker Docker Image

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$NVM_DIR' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
# Required for Corepack to dynamically modify binaries of supported package managers.
RUN sudo chgrp -R 0 /opt/nvm && chmod -R g+rwX /opt/nvm

Expand Down Expand Up @@ -252,7 +259,7 @@
&& gem install bundler cocoapods:$COCOAPODS_VERSION

FROM scratch AS ruby
COPY --from=rubybuild $RBENV_ROOT $RBENV_ROOT

Check warning on line 262 in workers/analyzer/docker/Analyzer.Dockerfile

View workflow job for this annotation

GitHub Actions / Build analyzer-worker Docker Image

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$RBENV_ROOT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

#------------------------------------------------------------------------
# RUST - Build as a separate component
Expand Down Expand Up @@ -301,7 +308,7 @@
RUN curl -sSL https://get.haskellstack.org/ | bash -s -- -d $HASKELL_HOME/bin

FROM scratch AS haskell
COPY --from=haskellbuild $HASKELL_HOME $HASKELL_HOME

Check warning on line 311 in workers/analyzer/docker/Analyzer.Dockerfile

View workflow job for this annotation

GitHub Actions / Build analyzer-worker Docker Image

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$HASKELL_HOME' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

#------------------------------------------------------------------------
# REPO / ANDROID SDK
Expand Down Expand Up @@ -333,7 +340,7 @@
&& sudo chmod a+x $ANDROID_HOME/cmdline-tools/bin/repo

FROM scratch AS android
COPY --from=androidbuild $ANDROID_HOME $ANDROID_HOME

Check warning on line 343 in workers/analyzer/docker/Analyzer.Dockerfile

View workflow job for this annotation

GitHub Actions / Build analyzer-worker Docker Image

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$ANDROID_HOME' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

#------------------------------------------------------------------------
# Dart
Expand All @@ -353,7 +360,7 @@
&& unzip /dart/dart.zip

FROM scratch AS dart
COPY --from=dartbuild $DART_SDK $DART_SDK

Check warning on line 363 in workers/analyzer/docker/Analyzer.Dockerfile

View workflow job for this annotation

GitHub Actions / Build analyzer-worker Docker Image

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$DART_SDK' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

#------------------------------------------------------------------------
# SBT
Expand All @@ -367,7 +374,7 @@
RUN curl -L https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz | tar -C /opt -xz

FROM scratch AS sbt
COPY --from=sbtbuild $DART_SDK $DART_SDK

Check warning on line 377 in workers/analyzer/docker/Analyzer.Dockerfile

View workflow job for this annotation

GitHub Actions / Build analyzer-worker Docker Image

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$DART_SDK' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

#------------------------------------------------------------------------
# SWIFT
Expand All @@ -389,7 +396,7 @@
| tar -xz -C $SWIFT_HOME --strip-components=2

FROM scratch AS swift
COPY --from=swiftbuild $SWIFT_HOME $SWIFT_HOME

Check warning on line 399 in workers/analyzer/docker/Analyzer.Dockerfile

View workflow job for this annotation

GitHub Actions / Build analyzer-worker Docker Image

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$SWIFT_HOME' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

#------------------------------------------------------------------------
# DOTNET
Expand Down Expand Up @@ -463,7 +470,7 @@

# Python
ENV PYENV_ROOT=/opt/python
ENV PATH=$PATH:$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PYENV_ROOT/conan2/bin
ENV PATH=$PATH:$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PYENV_ROOT/plugins/pyenv-virtualenv/shims
COPY --from=python --chown=$USER:$USER $PYENV_ROOT $PYENV_ROOT

# NodeJS
Expand Down
45 changes: 45 additions & 0 deletions workers/analyzer/docker/scripts/setup_conan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
#
# Copyright (C) 2025 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# License-Filename: LICENSE
#

conan_option=${CONAN_MAJOR_VERSION:-2}

# Since this script is installed with the name "conan", there is a risk of infinite recursion if pyenv is not available
# on the PATH, which can occur when setting up a development environment. To prevent this, check for recursive calls.
if [[ "$CONAN_RECURSIVE_CALL" -eq 1 ]]; then
echo "Recursive call detected. Exiting."
exit 1
fi

# Setup pyenv
eval "$(pyenv init - --no-rehash bash)"
eval "$(pyenv virtualenv-init -)"

# Setting up Conan 1.x
if [[ "$conan_option" -eq 1 ]]; then # Setting up Conan 1.x series
pyenv activate conan
# Docker has modern libc
CONAN_RECURSIVE_CALL=1 conan profile update settings.compiler.libcxx=libstdc++11 ort-default
elif [[ "$conan_option" -eq 2 ]]; then # Setting up Conan 2.x series
pyenv activate conan2
fi

# Runs conan from activated profile
CONAN_RECURSIVE_CALL=1 conan "$@"