-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add build-make-check-container job #1957
Open
djgalloway
wants to merge
1
commit into
main
Choose a base branch
from
build-make-check-container
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This is just the default. Overridden by `docker build --build-arg DISTRO=$DISTRO` at build time | ||
ARG DISTRO='ubuntu:20.04' | ||
FROM $DISTRO | ||
RUN if command -v yum; then \ | ||
yum install -y epel-release; \ | ||
yum install -y git sudo ccache clang; \ | ||
yum update -y; \ | ||
else \ | ||
apt update && DEBIAN_FRONTEND="noninteractive" apt install -y git-core sudo ccache; \ | ||
fi | ||
RUN git clone https://github.com/ceph/ceph /opt/ceph | ||
RUN git clone https://github.com/ceph/ceph-ci /opt/ceph-ci | ||
# Set some defaults (again, overridden using --build-arg) | ||
ARG INSTALL_DEPS_REPO=ceph | ||
ARG INSTALL_DEPS_BRANCH=master | ||
RUN cd /opt/$INSTALL_DEPS_REPO \ | ||
&& if ! git checkout $INSTALL_DEPS_BRANCH; then \ | ||
echo $INSTALL_DEPS_BRANCH doesn\'t exist; \ | ||
exit 1; \ | ||
fi \ | ||
&& DEBIAN_FRONTEND="noninteractive" ./install-deps.sh \ | ||
&& git submodule update --init --recursive | ||
# Doesn't work yet | ||
# # To populate ccache | ||
# && ./src/script/run-make.sh \ | ||
# && rm -rf build | ||
# Some defaults. Overridden by `docker run -e VAR=$VAR` at runtime | ||
ENV REPO=${REPO:-ceph} | ||
ENV BRANCH=${BRANCH:-master} | ||
ENV PULLREQUEST_ID=${PULLREQUEST_ID} | ||
# Uncertain on the proper order here. Do I need to `pull` after checking out the branch again? | ||
CMD cd /opt/$REPO \ | ||
&& git fetch --all \ | ||
&& if [ "$PULLREQUEST_ID" == "" ]; then \ | ||
echo "PULLREQUEST_ID was not defined. Using the \$BRANCH var"; \ | ||
echo -e "****************\n\nChecking out branch: $BRANCH\n\n****************"; \ | ||
git checkout $BRANCH; \ | ||
git pull; \ | ||
else \ | ||
echo -e "****************\n\nChecking out Pull Request ID: $PULLREQUEST_ID\n\n****************"; \ | ||
git fetch origin pull/$PULLREQUEST_ID/head:PR$PULLREQUEST_ID; \ | ||
git checkout PR$PULLREQUEST_ID; \ | ||
fi \ | ||
&& ./install-deps.sh \ | ||
&& timeout 3h ./run-make-check.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Uncomment these to run locally on your workstation | ||
#DISTRO="ubuntu:20.04" | ||
#DISTRO="centos:8" | ||
#BRANCH=${BRANCH:-master} | ||
#WORKSPACE=~/git/ceph/ceph-build | ||
|
||
DASHED_DISTRO=$(echo "$DISTRO" | sed 's/:/-/') | ||
|
||
cd "$WORKSPACE"/build-make-check-container/build | ||
|
||
sudo docker build --build-arg INSTALL_DEPS_BRANCH=$BRANCH --build-arg DISTRO=$DISTRO -t make-check:$BRANCH-$DASHED_DISTRO . | ||
|
||
sudo docker login -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}" quay.ceph.io | ||
|
||
sudo docker image tag make-check:$BRANCH-$DASHED_DISTRO quay.ceph.io/cephci/make-check:$BRANCH-$DASHED_DISTRO | ||
|
||
sudo docker push quay.ceph.io/cephci/make-check:$BRANCH-$DASHED_DISTRO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
if [[ $(command -v docker) == '' ]]; then | ||
# Set up docker official repo and install docker. | ||
sudo apt update -y | ||
sudo apt install \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg \ | ||
lsb-release | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | ||
echo \ | ||
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | ||
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt update -y | ||
sudo apt install -y docker-ce docker-ce-cli containerd.io | ||
fi | ||
sudo groupadd docker || true | ||
sudo usermod -aG docker $(id -un) | ||
sudo systemctl start docker | ||
sudo chgrp "$(id -un)" /var/run/docker.sock | ||
|
||
docker info | ||
docker container prune -f | ||
|
||
|
92 changes: 92 additions & 0 deletions
92
build-make-check-container/config/definitions/build-make-check-container.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
- job: | ||
name: build-make-check-container | ||
node: master | ||
project-type: matrix | ||
defaults: global | ||
display-name: 'Builds the ceph-make-check container and pushes to quay.ceph.io' | ||
quiet-period: 5 | ||
block-downstream: false | ||
block-upstream: false | ||
retry-count: 3 | ||
execution-strategy: | ||
combination-filter: | | ||
!(BRANCH=="master" && DISTRO=="centos:7") && | ||
!(BRANCH=="pacific" && DISTRO=="centos:7") && | ||
!(BRANCH=="master" && DISTRO=="ubuntu:18.04") && | ||
!(BRANCH=="pacific" && DISTRO=="ubuntu:18.04") | ||
properties: | ||
- build-discarder: | ||
days-to-keep: 14 | ||
|
||
# parameters: | ||
# - string: | ||
# name: BRANCH | ||
# description: "Base branch you want to the container to have install-deps run for" | ||
# default: master | ||
# | ||
# - string: | ||
# name: DISTRO | ||
# description: "Distro you want install-deps run on" | ||
# default: 'ubuntu:20.04' | ||
|
||
axes: | ||
- axis: | ||
type: label-expression | ||
name: MACHINE_SIZE | ||
values: | ||
- huge | ||
- axis: | ||
type: label-expression | ||
name: MACHINE_TYPE | ||
values: | ||
- focal | ||
- axis: | ||
type: label-expression | ||
name: MACHINE_ARCH | ||
values: | ||
- x86_64 | ||
|
||
- axis: | ||
type: user-defined | ||
name: BRANCH | ||
values: | ||
- master | ||
- octopus | ||
- pacific | ||
|
||
- axis: | ||
type: user-defined | ||
name: DISTRO | ||
values: | ||
- 'centos:7' | ||
- 'centos:8' | ||
- 'ubuntu:18.04' | ||
- 'ubuntu:20.04' | ||
|
||
triggers: | ||
- timed: '@daily' | ||
|
||
scm: | ||
- git: | ||
url: https://github.com/ceph/ceph-build.git | ||
branches: | ||
- build-make-check-container | ||
browser: auto | ||
timeout: 20 | ||
|
||
builders: | ||
- shell: | ||
!include-raw: | ||
# - ../../../scripts/build_utils.sh | ||
- ../../build/setup | ||
- ../../build/build | ||
|
||
wrappers: | ||
- inject-passwords: | ||
global: true | ||
mask-password-params: true | ||
- credentials-binding: | ||
- username-password-separated: | ||
credential-id: quay-ceph-io-make-check-bot | ||
username: REGISTRY_USERNAME | ||
password: REGISTRY_PASSWORD |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would try something like that:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
less steps, less layers, more readable...
just saying... 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will admit this is my first Dockerfile but I find yours to be far less readable.
Using mine, if one of the RUN steps fails, you can tell where and why right away vs. having to wait for the entire single RUN step in your suggestion. I don't want to end up with another one of these:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although there's not only the readability concern here, I was just suggesting, your call then... 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to being educated 😄. What do less steps and layers mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each operation (RUN, COPY, ...) adds a new layer, the more layer you have, the bigger your image size will be.
You might want to have a look at "multi-stage" builds.
https://docs.docker.com/develop/develop-images/multistage-build/