Skip to content

Commit 324e41e

Browse files
heliocastrosschuberth
authored andcommitted
Updated Docker logic with upstream ORT changes
Signed-off-by: Helio Chissini de Castro <[email protected]>
1 parent 544471e commit 324e41e

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

.gitlab-ci.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,19 +355,16 @@ ort-scan:
355355

356356
ort-build-image:
357357
stage: build
358-
image: docker:19.03.12
358+
image: docker:20.10.18-git
359359
services:
360-
- name: docker:19.03.12-dind
361-
alias: docker
360+
- docker:20.10.18-dind
362361
variables:
363362
DOCKER_BUILDKIT: 1
364363
DOCKER_DRIVER: overlay2
365364
before_script:
366-
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
365+
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
367366
script:
368-
- export ORT_DOCKERFILE_FILE=${ORT_DOCKERFILE_FILE:-"./Dockerfile"}
369367
- export ORT_SCANCODE_VERSION=${ORT_SCANCODE_VERSION:-"30.1.0"}
370-
- apk add --no-cache git
371368
- |
372369
if [[ -z "$ORT_REVISION" ]]; then
373370
echo "Building the vanilla ORT docker image 'ort'..."
@@ -378,39 +375,43 @@ ort-build-image:
378375
echo "Building the ORT docker image 'ort' based on commit ${ORT_REVISION}..."
379376
mkdir ort
380377
cd ort
381-
git config --global init.defaultBranch master
378+
git config --global init.defaultBranch main
382379
git init
383380
git remote add origin $ORT_URL
384381
git fetch --depth 1 origin $ORT_REVISION
385382
git checkout FETCH_HEAD
386383
ORT_REVISION=$(git rev-parse --short HEAD)
387384
fi
388-
- if [[ "$CI_DEFAULT_BRANCH" == "$CI_COMMIT_REF_NAME" ]]; then MAIN_TAG=latest; else MAIN_TAG="$CI_COMMIT_REF_NAME"; fi
389-
- docker build
385+
- if [[ "$CI_DEFAULT_BRANCH" == "$CI_COMMIT_REF_NAME" ]]; then MAIN_TAG=latest; else MAIN_TAG="$CI_COMMIT_SHORT_SHA"; fi
386+
- docker buildx build
390387
--cache-from $CI_REGISTRY_IMAGE/ort:latest
391388
--tag $CI_REGISTRY_IMAGE/ort:$ORT_REVISION
392389
--tag $CI_REGISTRY_IMAGE/ort:$MAIN_TAG
393390
--build-arg ORT_VERSION="$ORT_REVISION"
394391
--build-arg ORT_URL="$ORT_URL"
395392
--build-arg BUILDKIT_INLINE_CACHE=1
396393
--build-arg SCANCODE_VERSION="$ORT_SCANCODE_VERSION"
397-
-f $ORT_DOCKERFILE_FILE .
394+
-f ./Dockerfile .
398395
- docker push $CI_REGISTRY_IMAGE/ort:$ORT_REVISION
399396
- docker push $CI_REGISTRY_IMAGE/ort:$MAIN_TAG
400397
- cd ..
401398
- echo "Building the custom ORT docker image 'ort-custom'..."
402-
- docker build
399+
- docker buildx build
403400
--cache-from $CI_REGISTRY_IMAGE/ort-custom:latest
404401
--tag $CI_REGISTRY_IMAGE/ort-custom:$ORT_REVISION
405402
--tag $CI_REGISTRY_IMAGE/ort-custom:$MAIN_TAG
406403
--build-arg ORT_DOCKER_IMAGE="${CI_REGISTRY_IMAGE}/ort:latest"
407404
--build-arg BUILDKIT_INLINE_CACHE=1
408-
-f $ORT_DOCKERFILE_FILE .
405+
--platform linux/amd64
406+
-f ./Dockerfile .
409407
- docker push $CI_REGISTRY_IMAGE/ort-custom:$ORT_REVISION
410408
- docker push $CI_REGISTRY_IMAGE/ort-custom:$MAIN_TAG
411409
rules:
412410
- if: $CI_PIPELINE_SOURCE == "web" && $REBUILD_DOCKER_IMAGE == "true"
413411
- if: $CI_PIPELINE_SOURCE == "schedule" && $REBUILD_DOCKER_IMAGE == "true"
412+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
413+
when: always
414+
allow_failure: true
414415

415416
# Deploy ort-scan dashboard to GitLab pages
416417
pages:

Dockerfile

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@ ARG ORT_DOCKER_IMAGE=registry.gitlab.com/oss-review-toolkit/ort-gitlab-ci/ort:la
33

44
FROM $ORT_DOCKER_IMAGE
55

6-
RUN apt-get update && \
7-
apt-get install -y --no-install-recommends \
8-
# Platform tools
9-
build-essential \
6+
# If you execute privileged operations
7+
USER root
8+
9+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
10+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
11+
apt-get -qq update \
12+
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends \
1013
gettext-base \
1114
jq \
1215
# 32-bit compatibility (e.g. required for Android SDK)
1316
lib32z1 \
1417
# Languages
1518
mono-complete \
16-
php-cli \
17-
php-curl \
18-
php-mbstring \
19-
php-xml \
20-
rustc && \
21-
# Make the Android SDK writable for non-root-users to allow dynamic SDK installation.
22-
chmod a+w $ANDROID_HOME -R && \
2319
# Clean-up
24-
rm -rf /var/lib/apt/lists/*
20+
&& rm -rf /var/lib/apt/lists/*
21+
22+
USER ort
2523

26-
ENTRYPOINT []
24+
ENTRYPOINT []

0 commit comments

Comments
 (0)