Skip to content

Commit

Permalink
feat: initial ruby builder
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Mar 22, 2021
0 parents commit 6b05e85
Show file tree
Hide file tree
Showing 17 changed files with 1,219 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!Dockerfile
!bin
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
4 changes: 4 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>containerbase/.github"]
}
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: build

on:
push:
branches:
- main
- 'renovate/**'

pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
flavor: [focal, bionic]

env:
FLAVOR: ${{ matrix.flavor }} # build target, name required by binary-builder

steps:
- uses: actions/checkout@v2.3.4

- name: docker-config
uses: renovatebot/internal-tools@v1.3.6
with:
command: docker-config

- name: binary-builder
uses: renovatebot/internal-tools@v1.3.6
with:
command: binary-builder
dry-run: ${{github.ref != 'refs/heads/main'}}
build-args: FLAVOR
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v2.2.2
with:
name: ${{ env.FLAVOR }}
path: .cache/*.tar.xz
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.cache
node_modules
dist/
data/
.vs/
5 changes: 5 additions & 0 deletions .huskyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}
14 changes: 14 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
node_modules/
.vs/
dist/
coverage/
yarn.lock

.editorconfig
.*ignore
.npmrc
.yarnrc
.yarnclean

*.snap
*.sh
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#--------------------------------------
# Ubuntu flavor
#--------------------------------------
ARG FLAVOR

#--------------------------------------
# base images
#--------------------------------------
FROM ubuntu:bionic@sha256:4bc3ae6596938cb0d9e5ac51a1152ec9dcac2a1c50829c74abd9c4361e321b26 as build-bionic
FROM ubuntu:focal@sha256:b4f9e18267eb98998f6130342baacaeb9553f136142d40959a1b46d6401f0f2b as build-focal


#--------------------------------------
# builder images
#--------------------------------------
FROM build-${FLAVOR} as builder


ENTRYPOINT [ "dumb-init", "--", "builder.sh" ]

COPY bin /usr/local/bin

RUN install-builder.sh
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 WhiteSource Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
![build](https://github.com/containerbase/ruby/actions/workflows/build.yml/badge.svg)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/containerbase/ruby)
![GitHub](https://img.shields.io/github/license/containerbase/ruby)

# containerbase Ruby releases

Prebuild Ruby releases used by [containerbase/buildpack](https://github.com/containerbase/buildpack).

## Local development

Build the image

```bash
docker build -t builder --build-arg APT_PROXY=http://apt-proxy:3142 .
```

Test the image

```bash
docker run --rm -it -v ${PWD}/.cache:/cache -e DEBURG=true builder 3.0.0
```

`${PWD}/.cache` will contain packed releases after successful build.

Optional environment variables

- `APT_PROXY`: Set an APT http proxy for installing build deps
- `DEBUG`: Show verbose php build output
22 changes: 22 additions & 0 deletions bin/builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

VERSION=${1}

CODENAME=$(. /etc/os-release && echo ${VERSION_CODENAME})

NAME=ruby
BUILD_ARGS=

if [[ "${DEBUG}" == "true" ]]; then
BUILD_ARGS="-v"
fi

echo "Building ${NAME} ${VERSION} for ${CODENAME}"
ruby-build ${BUILD_ARGS} ${VERSION} /usr/local/${NAME}/${VERSION}

/usr/local/${NAME}/${VERSION}/bin/ruby -v

echo "Compressing ${NAME} ${VERSION} for ${CODENAME}"
tar -cJf /cache/${NAME}-${VERSION}-${CODENAME}.tar.xz -C /usr/local/${NAME} ${VERSION}
35 changes: 35 additions & 0 deletions bin/install-builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -e


echo "APT::Install-Recommends \"false\";" | tee -a /etc/apt/apt.conf.d/99buildpack.conf
echo "APT::Get::Upgrade \"false\";" | tee -a /etc/apt/apt.conf.d/99buildpack.conf
echo "APT::Get::Install-Suggests \"false\";" | tee -a /etc/apt/apt.conf.d/99buildpack.conf

if [[ ! -z "${APT_PROXY+x}" ]]; then
echo "Acquire::http::proxy \"${APT_PROXY}\";" | tee -a /etc/apt/apt.conf.d/99buildpack-proxy.conf
fi

export DEBIAN_FRONTEND=noninteractive

apt-get update -q
apt-get install -q -y \
build-essential \
ca-certificates \
curl \
dumb-init \
git \
libssl-dev \
libreadline-dev \
zlib1g-dev \
;

git clone https://github.com/rbenv/ruby-build.git
PREFIX=/usr/local ./ruby-build/install.sh

mkdir -p /usr/local/ruby /cache

if [[ ! -z "${APT_PROXY+x}" ]]; then
rm -f /etc/apt/apt.conf.d/99buildpack-proxy.conf
fi
8 changes: 8 additions & 0 deletions builder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"image": "ruby",
"depName": "ruby",
"datasource": "ruby-version",
"versioning": "ruby",
"startVersion": "2.5.0",
"ignoredVersions": ["2.5.0-preview1", "2.5.0-rc1", "2.5.2"]
}
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "containerbase-ruby",
"version": "1.0.0",
"private": true,
"license": "MIT",
"repository": "https://github.com/containerbase/ruby.git",
"author": "Michael Kriese <michael.kriese@visualon.de>",
"scripts": {
"lint": "run-s prettier",
"prettier": "prettier \"{**/*,*}.*\" --check --ignore-unknown",
"prettier:fix": "prettier \"{**/*,*}.*\" --write --ignore-unknown"
},
"devDependencies": {
"husky": "4.3.8",
"npm-run-all": "4.1.5",
"prettier": "2.2.1",
"prettier-plugin-package": "1.3.0",
"pretty-quick": "3.1.0"
}
}
15 changes: 15 additions & 0 deletions renovate.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#-------------------------
# renovate rebuild trigger
#-------------------------

# makes lint happy
FROM scratch


# renovate: datasource=ruby-version depName=ruby versioning=ruby
ENV RUBY_VERSION=2.7.2


# rebuild trigger
# renovate: datasource=ruby-version depName=ruby versioning=ruby
ENV RUBY_VERSION=3.0.0
Loading

0 comments on commit 6b05e85

Please sign in to comment.