Skip to content

Commit

Permalink
Update Dockerfile rvm version to 2.7 (#892)
Browse files Browse the repository at this point in the history
* Update Dockerfile rvm version to 2.7

* Add ruby_version are to Build dockerfiles

* Add initial container build workflow

* Add initial container build workflow

* Add initial container build workflow
  • Loading branch information
op-ct authored Jul 19, 2023
1 parent ceade0e commit ae3ed99
Showing 6 changed files with 117 additions and 9 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build_containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: 'RELENG: Build + publish SIMP container image'

on:
workflow_dispatch:
inputs:
ruby_version:
description: "Ruby verion build arg"
required: true
options:
- 2.7
- 3.1
dockerfile:
# description: >
# Filename of SIMP Dockerfile to build
# (under `build/Dockerfiles/`)
# Example: `SIMP_EL7_Build.dockerfile`
required: true
container_name:
# description: >
# Name of container to push
# Examples: `simp_beaker_el7`, `simp_build_centos7`
required: true
container_tag:
# description: >
# Tag of container to push
# Examples: `latest`, `20230703`
required: true
default: latest
registry_repo:
required: true
# description: >
# Dockerhub + repo to push to
default: 'docker.io/simpproject'
registry_user:
required: true
registry_password:
required: true
git_ref:
required: true
default: master
jobs:
build_container:
name: Build and push container
runs-on: ubuntu-latest
steps:
#- name: install docker
# run: |
# set -x
# sudo apt-get remove -y podman ||:
# sudo apt-get install -y docker-ce docker docker-engine docker.io containerd runc ||:
# sudo apt-get update
# sudo apt autoremove -y
# sudo systemctl start docker
- uses: actions/checkout@v3

- name: build
env:
RUBY_VERSION: ${{github.event.inputs.ruby_version}}
DOCKERFILE: ${{github.event.inputs.dockerfile}}
CONTAINER_NAME: ${{github.event.inputs.container_name}}
CONTAINER_TAG: ${{github.event.inputs.container_tag}}
REGISTRY_USER: ${{github.event.inputs.registry_user}}
REGISTRY_PASSWORD: ${{github.event.inputs.registry_password}}
REGISTRY_REPO: ${{github.event.inputs.registry_repo}}
run: |
cd build/Dockerfiles
docker build --build-arg ruby_version="$RUBY_VERSION" -f "$DOCKERFILE" -t "$CONTAINER_TAG"
echo "$REGISTRY_PASSWORD" | docker login --username "$REGISTRY_USER" --password-stdin
docker push "$CONTAINER_NAME:CONTAINER_TAG"
13 changes: 13 additions & 0 deletions build/Dockerfiles/README.md
Original file line number Diff line number Diff line change
@@ -13,7 +13,20 @@ you are setting up your own development system from scratch.

`buildah build -t <friendly image name> -f <Dockerfile> .`

### Build args

The `SIMP_*_Build.dockerfile` builds support a `--build-arg` to set the initial
`ruby_version` of RVM:

```
buildah build -t simp_build_centos8_ruby3_1 --build-arg ruby_version=3.1 -f SIMP_EL8_Build.dockerfile
```

The current default for this argument is `2.7` (to support Puppet 7)


## Pushing

If you build using `buildah`, you'll need to make sure you push to Dockerhub
using `podman push --format=docker ...`

3 changes: 2 additions & 1 deletion build/Dockerfiles/SIMP_EL7_Build.dockerfile
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@

FROM centos:7.0.1406
ENV container docker
ARG ruby_version=2.7

RUN mkdir /root/build_scripts
ADD scripts/common/* /root/build_scripts/
@@ -45,7 +46,7 @@ RUN ./01_disable_systemctl.sh
RUN ./05_selinux.sh
RUN ./10_dev_packages.sh
RUN ./user.sh
RUN ./rvm.sh
RUN ./rvm.sh "$ruby_version"
RUN ./prime_ruby.sh
RUN ./package_cleanup.sh
RUN rm -rf /root/build_scripts
3 changes: 2 additions & 1 deletion build/Dockerfiles/SIMP_EL8_Build.dockerfile
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
#FROM centos:8
FROM centos:centos8.1.1911
ENV container docker
ARG ruby_version=2.7

RUN mkdir /root/build_scripts
ADD scripts/common/* /root/build_scripts/
@@ -23,7 +24,7 @@ RUN ./minimize_package_installs.sh
RUN ./05_selinux.sh
RUN ./10_dev_packages.sh
RUN ./user.sh
RUN ./rvm.sh
RUN ./rvm.sh build_user "$ruby_version"
RUN ./prime_ruby.sh
RUN ./package_cleanup.sh
RUN rm -rf /root/build_scripts
11 changes: 4 additions & 7 deletions build/Dockerfiles/scripts/common/rvm.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/bin/sh -e

user_id="$1"

if [ -z "$user_id" ]; then
user_id='build_user'
fi
user_id="${1:-build_user}"
ruby_version="${2:-2.7}"

# Set up RVM
runuser $user_id -l -c "echo 'gem: --no-document' > .gemrc"
@@ -27,7 +24,7 @@ key_id='7D2BAF1CF37B13E2069D6956105BD0E739499BDB'
runuser $user_id -l -c "for i in {1..5}; do { gpg2 --keyserver hkp://keys.openpgp.org --recv-keys $key_id || gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys $key_id; } && break || sleep 1; done"
#runuser $user_id -l -c "gpg2 --refresh-keys"
runuser $user_id -l -c "curl -sSL https://raw.githubusercontent.com/rvm/rvm/stable/binscripts/rvm-installer -o rvm-installer && curl -sSL https://raw.githubusercontent.com/rvm/rvm/stable/binscripts/rvm-installer.asc -o rvm-installer.asc && gpg2 --verify rvm-installer.asc rvm-installer && bash rvm-installer"
runuser $user_id -l -c "rvm install 2.6"
runuser $user_id -l -c "rvm use --default 2.6"
runuser $user_id -l -c "rvm install ${ruby_version}"
runuser $user_id -l -c "rvm use --default ${ruby_version}"
runuser $user_id -l -c "rvm all do gem install bundler -v '~> 1.16'"
runuser $user_id -l -c "rvm all do gem install bundler -v '~> 2.0'"
23 changes: 23 additions & 0 deletions build/distributions/CentOS/8Stream/release_mappings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# This file houses the *officially supported* SIMP release combinations
# Other build combinations may work, but unexpected issues may arise.
simp_releases:
6.X:
flavors:
CentOS:
isos:
- name: 'CentOS-Stream-8-x86_64-20230125-dvd1.iso'
size: 11766071296
checksum: '91454029bf70382eff9032d384093747d588ce4c96d95028b1c21b6f8154c712'
build_command: 'bundle exec rake build:auto[CentOS-Stream-8-x86_64-20230125-dvd1.iso,6.6]'
os_version: '8.7'
'6.6':
flavors:
CentOS:
isos:
- name: 'CentOS-Stream-8-x86_64-20230125-dvd1.iso'
size: 11766071296
checksum: '91454029bf70382eff9032d384093747d588ce4c96d95028b1c21b6f8154c712'
build_command: 'bundle exec rake build:auto[CentOS-Stream-8-x86_64-20230125-dvd1.iso,6.6]'
os_version: '8.7'

0 comments on commit ae3ed99

Please sign in to comment.