Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,66 @@ on:
push:
branches:
- master
pull_request:
schedule:
- cron: "0 2 * * 0"

env:
DOCKER_BUILDKIT: 1
FEDORA_VERSION: 34
FEDORA_VERSION: 35

jobs:
lint:
jemalloc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: hadolint/hadolint-action@v2.0.0
with:
dockerfile: Dockerfile
config: hadolint-ci.yaml

push:
runs-on: ubuntu-latest
needs: lint
permissions:
packages: write
contents: read

strategy:
matrix:
ruby: [
'2.5',
'2.6',
'2.7'
'2.7',
'3.0'
]

steps:
- uses: actions/checkout@v3

- uses: hadolint/hadolint-action@v2.0.0
with:
dockerfile: Dockerfile
config: hadolint-ci.yaml

- name: Set image name
run: |
echo "DOCKER_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/ruby" >> ${GITHUB_ENV}
run: echo "DOCKER_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/ruby" >> ${GITHUB_ENV}

- name: render docker-compose.yml
- name: Render docker-compose.yml
run: RUBY_VERSION=${{ matrix.ruby }} envsubst < docker-compose.yml.tmpl > docker-compose.yml

- name: Build image
run: docker-compose -f docker-compose.yml build ruby
run: docker-compose -f docker-compose.yml build ruby-jemalloc

- name: Tag image
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: |
docker tag ruby:${{ matrix.ruby }} ${DOCKER_IMAGE}:${{ matrix.ruby }}
docker tag ruby:${{ matrix.ruby }} ${DOCKER_IMAGE}:${{ matrix.ruby }}-${{ github.run_number }}
docker tag ruby:${{ matrix.ruby }}-jemalloc ${DOCKER_IMAGE}:${{ matrix.ruby }}-jemalloc
docker tag ruby:${{ matrix.ruby }}-jemalloc ${DOCKER_IMAGE}:${{ matrix.ruby }}-jemalloc-${{ github.run_number }}

- name: Log into registry
# This is where you will update the PAT to GITHUB_TOKEN
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
- name: Push images
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: |
docker push ${DOCKER_IMAGE}:${{ matrix.ruby }}
docker push ${DOCKER_IMAGE}:${{ matrix.ruby }}-${{ github.run_number }}
docker push ${DOCKER_IMAGE}:${{ matrix.ruby }}-jemalloc
docker push ${DOCKER_IMAGE}:${{ matrix.ruby }}-jemalloc-${{ github.run_number }}

- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
if: ${{ success() }}
env:
SLACK_WEBHOOK: ${{ secrets.BUILD_NOTIFY_SLACK }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: green
SLACK_MESSAGE: 'Good luck, this time... :rocket:'
SLACK_TITLE: Build successful
Expand All @@ -76,7 +71,7 @@ jobs:
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() }}
env:
SLACK_WEBHOOK: ${{ secrets.BUILD_NOTIFY_SLACK }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: red
SLACK_MESSAGE: 'Seems whatever you did failed :unrocket:'
SLACK_TITLE: Build failed
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- master
pull_request:
schedule:
- cron: "0 2 * * 0"

Expand All @@ -12,53 +11,48 @@ env:
FEDORA_VERSION: 35

jobs:
lint:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: hadolint/hadolint-action@v2.0.0
with:
dockerfile: Dockerfile
config: hadolint-ci.yaml

push:
runs-on: ubuntu-latest
needs: lint
if: github.event_name != 'pull_request'
permissions:
packages: write
contents: read

strategy:
matrix:
ruby: [
'2.7',
'3.0'
]

steps:
- uses: actions/checkout@v3

- uses: hadolint/hadolint-action@v2.0.0
with:
dockerfile: Dockerfile
config: hadolint-ci.yaml

- name: Set image name
run: |
echo "DOCKER_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/ruby" >> ${GITHUB_ENV}
run: echo "DOCKER_IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/ruby" >> ${GITHUB_ENV}

- name: render docker-compose.yml
- name: Render docker-compose.yml
run: RUBY_VERSION=${{ matrix.ruby }} envsubst < docker-compose.yml.tmpl > docker-compose.yml

- name: Build image
run: docker-compose -f docker-compose.yml build ruby

- name: Tag image
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: |
docker tag ruby:${{ matrix.ruby }} ${DOCKER_IMAGE}:${{ matrix.ruby }}
docker tag ruby:${{ matrix.ruby }} ${DOCKER_IMAGE}:${{ matrix.ruby }}-${{ github.run_number }}

- name: Log into registry
# This is where you will update the PAT to GITHUB_TOKEN
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
- name: Push images
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: |
docker push ${DOCKER_IMAGE}:${{ matrix.ruby }}
docker push ${DOCKER_IMAGE}:${{ matrix.ruby }}-${{ github.run_number }}
Expand All @@ -67,7 +61,7 @@ jobs:
uses: rtCamp/action-slack-notify@v2
if: ${{ success() }}
env:
SLACK_WEBHOOK: ${{ secrets.BUILD_NOTIFY_SLACK }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: green
SLACK_MESSAGE: 'Good luck, this time... :rocket:'
SLACK_TITLE: Build successful
Expand All @@ -76,7 +70,7 @@ jobs:
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() }}
env:
SLACK_WEBHOOK: ${{ secrets.BUILD_NOTIFY_SLACK }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: red
SLACK_MESSAGE: 'Seems whatever you did failed :unrocket:'
SLACK_TITLE: Build failed
20 changes: 17 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ARG FEDORA_VERSION
FROM registry.fedoraproject.org/fedora-minimal:${FEDORA_VERSION}
FROM registry.fedoraproject.org/fedora-minimal:${FEDORA_VERSION} as bare

ARG RUBY_VERSION

RUN microdnf --nodocs -y upgrade && \
microdnf --nodocs -y install fedora-repos-modular && \
microdnf module enable -y ruby:${RUBY_VERSION} && \
Expand All @@ -23,7 +24,6 @@ RUN microdnf --nodocs -y upgrade && \
libxml2-devel \
libxslt-devel \
make \
nano \
nodejs \
openssl-devel \
patch \
Expand All @@ -41,8 +41,22 @@ RUN microdnf --nodocs -y upgrade && \
microdnf --nodocs reinstall -y tzdata && \
microdnf clean all

RUN gem install bundler


FROM bare as base

ONBUILD ARG UID=1000
ONBUILD RUN useradd -d /ruby -l -m -Uu ${UID} -r -s /bin/bash ruby && \
chown -R ${UID}:${UID} /ruby

RUN gem install bundler

FROM bare as jemalloc

ONBUILD ARG UID=1000
ONBUILD RUN useradd -d /ruby -l -m -Uu ${UID} -r -s /bin/bash ruby && \
chown -R ${UID}:${UID} /ruby

RUN microdnf --nodocs install -y jemalloc

ENV LD_PRELOAD=/usr/lib64/libjemalloc.so.2
11 changes: 11 additions & 0 deletions docker-compose.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ services:
build:
context: .
dockerfile: Dockerfile
target: base
args:
- RUBY_VERSION=${RUBY_VERSION}
- FEDORA_VERSION=${FEDORA_VERSION}
image: ruby:${RUBY_VERSION}

ruby-jemalloc:
build:
context: .
dockerfile: Dockerfile
target: jemalloc
args:
- RUBY_VERSION=${RUBY_VERSION}
- FEDORA_VERSION=${FEDORA_VERSION}
image: ruby:${RUBY_VERSION}-jemalloc
1 change: 1 addition & 0 deletions hadolint-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ignored:
- DL3041 # Specify version with dnf install -y <package>-<version>
- DL4006 # Set the SHELL option -o pipefail before RUN with a pipe in
- DL3028 # Pin version of gem install
- DL3040 # `dnf clean all` missing after dnf command (as microdnf is used)