Skip to content

Commit 31845bf

Browse files
committed
Add Dockerfile and build actions
1 parent eaf7c7a commit 31845bf

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Docker build
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
docker-build:
9+
runs-on: ubuntu-24.04
10+
env:
11+
DOCKER_REPO: ghcr.io/${{ github.repository }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Build Docker image
15+
run: RUBY_VERSION=3.3.4 NODE_VERSION=22.16.0 ./build.sh

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This Dockerfile is designed for running the CI of Ruby on Rails projects
2+
ARG RUBY_VERSION=3.4.4
3+
FROM docker.io/library/ruby:$RUBY_VERSION
4+
5+
RUN apt-get update -qq && \
6+
apt-get install --no-install-recommends -y postgresql-client libjemalloc2 && \
7+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
8+
9+
# Install yarn and node
10+
ARG NODE_VERSION=22.14.0
11+
ARG YARN_VERSION=1.22.22
12+
ENV PATH=/usr/local/node/bin:$PATH
13+
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
14+
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
15+
npm install -g yarn@$YARN_VERSION && \
16+
rm -rf /tmp/node-build-master
17+
18+
ENV RAILS_ENV="test"

build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
if [ -z "${RUBY_VERSION:-}" ]; then
6+
echo "RUBY_VERSION is not set"
7+
exit 1
8+
fi
9+
10+
if [ -z "${NODE_VERSION:-}" ]; then
11+
echo "NODE_VERSION is not set"
12+
exit 1
13+
fi
14+
15+
docker build -t "${DOCKER_REPO}:ruby-${RUBY_VERSION}-node-${NODE_VERSION}" .

0 commit comments

Comments
 (0)