Skip to content

Commit

Permalink
Merge pull request #2 from linuxfrorg/ruby3
Browse files Browse the repository at this point in the history
The board is now compatible with ruby 3
  • Loading branch information
Trim authored Mar 9, 2024
2 parents 172bc71 + a1ab5ae commit d6ae3fd
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 57 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.git
/.github
/deployment
.*.swp
25 changes: 25 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build the ruby gem in a container
on:
pull_request:

jobs:
build-ruby-gem:
runs-on: ubuntu-latest
steps:
- name: Checkout project code
uses: actions/checkout@v4

- name: Setup Docker builder
uses: docker/setup-buildx-action@v3

- name: Build container for build target
uses: docker/build-push-action@v5
with:
context: .
file: ./deployment/Containerfile
target: build
push: false
load: true
tags: linuxfrorg/board-sse-linuxfr.org:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
47 changes: 47 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build the ruby gem in a container and publish it on Github Package Repository
on:
release:
types:
- published

jobs:
build-ruby-gem:
runs-on: ubuntu-latest
steps:
- name: Checkout project code
uses: actions/checkout@v4

- name: Setup Docker builder
uses: docker/setup-buildx-action@v3

- name: Build container for build target
uses: docker/build-push-action@v5
with:
context: .
file: ./deployment/Containerfile
target: build
push: false
load: true
tags: linuxfrorg/board-sse-linuxfr.org:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Publish gem to Github Package Repository
uses: addnab/docker-run-action@v3
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}
with:
image: linuxfrorg/board-sse-linuxfr.org:${{ github.sha }}
options: >-
-e OWNER
-e GEM_HOST_API_KEY
run: |
set -eux
IFS=$'\n\t'
mkdir -p "${HOME}/.gem"
touch "${HOME}/.gem/credentials"
chmod 0600 "${HOME}/.gem/credentials"
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > "${HOME}/.gem/credentials"
gem push --KEY github --host "https://rubygems.pkg.github.com/${OWNER}" *.gem
14 changes: 7 additions & 7 deletions board-linuxfr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ require './lib/board-linuxfr/version'
Gem::Specification.new do |s|
s.name = "board-linuxfr"
s.version = BoardLinuxfr::VERSION
s.authors = ["Bruno Michel"]
s.email = "[email protected]"
s.authors = ["Bruno Michel", "Adrien Dorsaz"]
s.email = "[email protected]"
s.homepage = "https://github.com/linuxfrorg/board-sse-linuxfr.org"
s.summary = "Push notifications for the board of LinuxFr.org via Server-Sent Events"
s.description = "Push notifications for the board of LinuxFr.org via Server-Sent Events"

s.files = `git ls-files bin lib`.split("\n")
s.files = Dir['lib/**/*.rb'] + Dir['bin/*']
s.platform = Gem::Platform::RUBY
s.executables = ["board-linuxfr"]
s.require_path = 'lib'

s.add_dependency "goliath", "~>1.0"
s.add_dependency "hiredis", "~>0.4"
s.add_dependency "redis", "~>3.0"
s.add_dependency "yajl-ruby", "~>1.2"
s.add_runtime_dependency "goliath", "~>1.0", ">= 1.0.7"
s.add_runtime_dependency "hiredis", "~>0.4"
s.add_runtime_dependency "redis", "~>3.0"
s.add_runtime_dependency "yajl-ruby", "~>1.2"

s.add_development_dependency "minitest", "~>2.3"
end
18 changes: 18 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
linuxfr-board:
build:
context: .
dockerfile: ./deployment/Containerfile
env_file:
- deployment/default.env
depends_on:
- redis

redis:
image: redis:5
volumes:
- data-redis:/data

volumes:
data-redis:
driver: local
45 changes: 45 additions & 0 deletions deployment/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM ruby:3-slim-bookworm AS build

LABEL org.opencontainers.image.title="LinuxFr.org boards"
LABEL org.opencontainers.image.description="Chat rooms for LinuxFr"
LABEL org.opencontainers.image.source="https://github.com/linuxfrorg/board-sse-linuxfr.org"
LABEL org.opencontainers.image.url="https://github.com/linuxfrorg/board-sse-linuxfr.org"
LABEL org.opencontainers.image.licenses="AGPL-3.0-only"
LABEL org.opencontainers.image.version="ruby3-bookworm"
LABEL org.opencontainers.image.authors="Adrien Dorsaz <[email protected]>"

ARG UID=1200

RUN <<EOF
set -eux
IFS=$'\n\t'

apt-get update

apt-get install -y --no-install-recommends \
build-essential ruby ruby-dev

apt-get clean
EOF

USER ${UID}
WORKDIR /linuxfr-board
ENV HOME=/linuxfr-board

# Install board-linuxfr
COPY --chown=${UID}:0 --chmod=770 . .
RUN gem build board-linuxfr.gemspec

FROM build as productioproduction

RUN gem install ./board-linuxfr-*.gem

# Clean development dependencies
USER 0
RUN apt purge --autoremove -y build-essential ruby-dev

USER ${UID}
EXPOSE 9000

CMD ["board-linuxfr"]

3 changes: 3 additions & 0 deletions deployment/default.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_URL=redis://redis:6379/0
1 change: 0 additions & 1 deletion lib/board-linuxfr.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "goliath"
require "board-linuxfr/monkeypatch"
require "yajl"


Expand Down
48 changes: 0 additions & 48 deletions lib/board-linuxfr/monkeypatch.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/board-linuxfr/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class BoardLinuxfr
VERSION = "0.1.3"
VERSION = "0.1.4"
end

0 comments on commit d6ae3fd

Please sign in to comment.