Skip to content

Commit d6ae3fd

Browse files
authored
Merge pull request #2 from linuxfrorg/ruby3
The board is now compatible with ruby 3
2 parents 172bc71 + a1ab5ae commit d6ae3fd

File tree

10 files changed

+150
-57
lines changed

10 files changed

+150
-57
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.git
2+
/.github
3+
/deployment
4+
.*.swp

.github/workflows/build.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build the ruby gem in a container
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
build-ruby-gem:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout project code
10+
uses: actions/checkout@v4
11+
12+
- name: Setup Docker builder
13+
uses: docker/setup-buildx-action@v3
14+
15+
- name: Build container for build target
16+
uses: docker/build-push-action@v5
17+
with:
18+
context: .
19+
file: ./deployment/Containerfile
20+
target: build
21+
push: false
22+
load: true
23+
tags: linuxfrorg/board-sse-linuxfr.org:${{ github.sha }}
24+
cache-from: type=gha
25+
cache-to: type=gha,mode=max

.github/workflows/release.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build the ruby gem in a container and publish it on Github Package Repository
2+
on:
3+
release:
4+
types:
5+
- published
6+
7+
jobs:
8+
build-ruby-gem:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout project code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Docker builder
15+
uses: docker/setup-buildx-action@v3
16+
17+
- name: Build container for build target
18+
uses: docker/build-push-action@v5
19+
with:
20+
context: .
21+
file: ./deployment/Containerfile
22+
target: build
23+
push: false
24+
load: true
25+
tags: linuxfrorg/board-sse-linuxfr.org:${{ github.sha }}
26+
cache-from: type=gha
27+
cache-to: type=gha,mode=max
28+
29+
- name: Publish gem to Github Package Repository
30+
uses: addnab/docker-run-action@v3
31+
env:
32+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
33+
OWNER: ${{ github.repository_owner }}
34+
with:
35+
image: linuxfrorg/board-sse-linuxfr.org:${{ github.sha }}
36+
options: >-
37+
-e OWNER
38+
-e GEM_HOST_API_KEY
39+
run: |
40+
set -eux
41+
IFS=$'\n\t'
42+
43+
mkdir -p "${HOME}/.gem"
44+
touch "${HOME}/.gem/credentials"
45+
chmod 0600 "${HOME}/.gem/credentials"
46+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > "${HOME}/.gem/credentials"
47+
gem push --KEY github --host "https://rubygems.pkg.github.com/${OWNER}" *.gem

board-linuxfr.gemspec

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ require './lib/board-linuxfr/version'
66
Gem::Specification.new do |s|
77
s.name = "board-linuxfr"
88
s.version = BoardLinuxfr::VERSION
9-
s.authors = ["Bruno Michel"]
10-
s.email = "[email protected]"
9+
s.authors = ["Bruno Michel", "Adrien Dorsaz"]
10+
s.email = "[email protected]"
1111
s.homepage = "https://github.com/linuxfrorg/board-sse-linuxfr.org"
1212
s.summary = "Push notifications for the board of LinuxFr.org via Server-Sent Events"
1313
s.description = "Push notifications for the board of LinuxFr.org via Server-Sent Events"
1414

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

20-
s.add_dependency "goliath", "~>1.0"
21-
s.add_dependency "hiredis", "~>0.4"
22-
s.add_dependency "redis", "~>3.0"
23-
s.add_dependency "yajl-ruby", "~>1.2"
20+
s.add_runtime_dependency "goliath", "~>1.0", ">= 1.0.7"
21+
s.add_runtime_dependency "hiredis", "~>0.4"
22+
s.add_runtime_dependency "redis", "~>3.0"
23+
s.add_runtime_dependency "yajl-ruby", "~>1.2"
2424

2525
s.add_development_dependency "minitest", "~>2.3"
2626
end

compose.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
linuxfr-board:
3+
build:
4+
context: .
5+
dockerfile: ./deployment/Containerfile
6+
env_file:
7+
- deployment/default.env
8+
depends_on:
9+
- redis
10+
11+
redis:
12+
image: redis:5
13+
volumes:
14+
- data-redis:/data
15+
16+
volumes:
17+
data-redis:
18+
driver: local

deployment/Containerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
FROM ruby:3-slim-bookworm AS build
2+
3+
LABEL org.opencontainers.image.title="LinuxFr.org boards"
4+
LABEL org.opencontainers.image.description="Chat rooms for LinuxFr"
5+
LABEL org.opencontainers.image.source="https://github.com/linuxfrorg/board-sse-linuxfr.org"
6+
LABEL org.opencontainers.image.url="https://github.com/linuxfrorg/board-sse-linuxfr.org"
7+
LABEL org.opencontainers.image.licenses="AGPL-3.0-only"
8+
LABEL org.opencontainers.image.version="ruby3-bookworm"
9+
LABEL org.opencontainers.image.authors="Adrien Dorsaz <[email protected]>"
10+
11+
ARG UID=1200
12+
13+
RUN <<EOF
14+
set -eux
15+
IFS=$'\n\t'
16+
17+
apt-get update
18+
19+
apt-get install -y --no-install-recommends \
20+
build-essential ruby ruby-dev
21+
22+
apt-get clean
23+
EOF
24+
25+
USER ${UID}
26+
WORKDIR /linuxfr-board
27+
ENV HOME=/linuxfr-board
28+
29+
# Install board-linuxfr
30+
COPY --chown=${UID}:0 --chmod=770 . .
31+
RUN gem build board-linuxfr.gemspec
32+
33+
FROM build as productioproduction
34+
35+
RUN gem install ./board-linuxfr-*.gem
36+
37+
# Clean development dependencies
38+
USER 0
39+
RUN apt purge --autoremove -y build-essential ruby-dev
40+
41+
USER ${UID}
42+
EXPOSE 9000
43+
44+
CMD ["board-linuxfr"]
45+

deployment/default.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
REDIS_HOST=redis
2+
REDIS_PORT=6379
3+
REDIS_URL=redis://redis:6379/0

lib/board-linuxfr.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require "goliath"
2-
require "board-linuxfr/monkeypatch"
32
require "yajl"
43

54

lib/board-linuxfr/monkeypatch.rb

Lines changed: 0 additions & 48 deletions
This file was deleted.

lib/board-linuxfr/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class BoardLinuxfr
2-
VERSION = "0.1.3"
2+
VERSION = "0.1.4"
33
end

0 commit comments

Comments
 (0)