Skip to content

Commit

Permalink
feat(docker): Add Dart component
Browse files Browse the repository at this point in the history
Signed-off-by: Helio Chissini de Castro <heliocastro@gmail.com>
  • Loading branch information
heliocastro committed Sep 5, 2023
1 parent 5596a4a commit 0021326
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 1 deletion.
91 changes: 91 additions & 0 deletions .github/workflows/docker-ort-dart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright (C) 2023 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

name: Ort Docker Dart Container

on:
workflow_dispatch:
pull_request:
branches:
- main
push:
paths:
- '.ortversions/dart.versions'
- '.github/workflows/docker-ort-base.yml'
workflow_run:
workflows: ["Ort Docker Base Image"]
types:
- completed

env:
REGISTRY: ghcr.io

permissions: write-all

jobs:
build:
name: Build ORT Dart Image
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write

steps:
- name: Checkout main repository
uses: actions/checkout@v3

- name: Set environment variables
run: |
cat .ortversions/dart.versions >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract components metadata (tags, labels) for base image
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}/dart
tags: |
type=semver,pattern={{version}},value=${{ env.DART_VERSION }}
- name: Build ORT Dart container
uses: docker/build-push-action@v4
with:
context: .
target: dart
push: ${{ github.event_name == 'push' }}
load: false
build-args: |
DART_VERSION=${{ env.DART_VERSION }}
tags: |
${{ steps.meta.outputs.tags }}
${{ env.REGISTRY }}/${{ github.repository }}/dart:latest
labels: ${{ steps.meta.outputs.labels }}
build-contexts: |
ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest
cache-from: type=gha,scope=ortdart
cache-to: type=gha,scope=ortdart,mode=max
1 change: 1 addition & 0 deletions .ortversions/dart.versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DART_VERSION=2.18.4
2 changes: 1 addition & 1 deletion scripts/custom_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
DOCKER_IMAGE_ROOT="${DOCKER_IMAGE_ROOT:-ghcr.io/oss-review-toolkit}"

# Define the list of valid components
valid_components=("rust" "ruby" "android" "golang" "swift" "sbt")
valid_components=("rust" "ruby" "android" "golang" "swift" "sbt" "dart")

# Define the Dockerfile template
dockerfile_template="FROM ghcr.io/oss-review-toolkit/ort\n"
Expand Down
8 changes: 8 additions & 0 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,11 @@ image_build swift swift "$SWIFT_VERSION" \
image_build sbt sbt "$SBT_VERSION" \
--build-arg SBT_VERSION="$SBT_VERSION" \
"$@"

# Dart
# SBT
# shellcheck disable=SC1091
. .ortversions/dart.versions
image_build dart dart "$DART_VERSION" \
--build-arg DART_VERSION="$DART_VERSION" \
"$@"
22 changes: 22 additions & 0 deletions scripts/docker_snippets/dart.snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2023 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

ENV DART_SDK=/opt/dart-sdk
ENV PATH=$PATH:$DART_SDK/bin
COPY --from=ghcr.io/oss-review-toolkit/dart --chown=$USER:$USER $DART_SDK $DART_SDK

RUN syft $DART_SDK -o spdx-json --file /usr/share/doc/ort/ort-golang.dart.json

0 comments on commit 0021326

Please sign in to comment.