Skip to content

Commit 6f87bca

Browse files
committed
docker
1 parent 22af8cc commit 6f87bca

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
max-parallel: 2
1111
fail-fast: false
1212
matrix:
13-
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2.0-preview3']
13+
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
1414
activerecord-version: ['5.0', '5.1', '5.2', '6.0', '6.1', '7.0', '7.1']
1515
exclude:
1616
# Rails 7's gemspec requires ruby >= 2.7
@@ -30,14 +30,14 @@ jobs:
3030
activerecord-version: '5.1'
3131
- ruby-version: '3.1'
3232
activerecord-version: '5.2'
33-
- ruby-version: '3.2.0-preview3'
33+
- ruby-version: '3.2'
3434
activerecord-version: '5.0'
35-
- ruby-version: '3.2.0-preview3'
35+
- ruby-version: '3.2'
3636
activerecord-version: '5.1'
37-
- ruby-version: '3.2.0-preview3'
37+
- ruby-version: '3.2'
3838
activerecord-version: '5.2'
3939
# This can't install sqlite3 and I have no idea why
40-
- ruby-version: '3.2.0-preview3'
40+
- ruby-version: '3.2'
4141
activerecord-version: '7.1'
4242

4343
steps:

Dockerfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# To create an image for a version of ruby, run e.g.:
2+
3+
# docker build -t udi278 --build-arg ruby_version=2.7.8 --build-arg activerecord_version=5.2 .
4+
# docker run --name udc278 -dit udi278
5+
# docker exec -it udc278 bash --login
6+
# docker stop udc278 && docker remove udc278
7+
8+
# (Any bundler_version is okay as long as its required_ruby_version is not >= 3.0.0.)
9+
10+
FROM debian:bookworm
11+
SHELL ["/bin/bash", "-c"]
12+
ENV WORKDIR=/app
13+
WORKDIR ${WORKDIR}
14+
RUN apt update && \
15+
apt upgrade -qy && \
16+
apt install -qy default-mysql-client postgresql-client libyaml-dev git less procps vim && \
17+
apt install -qy rbenv && \
18+
rm -rf /var/lib/apt/lists/*
19+
20+
ARG ruby_version=3.1.2
21+
ARG activerecord_version=7.0
22+
ARG bundler_version=2.4.22
23+
ENV BUNDLE_GEMFILE="${WORKDIR}/gemfiles/activerecord_${activerecord_version}.gemfile"
24+
25+
# We install rbenv, which also installs ruby-build as well as all the dependencies they
26+
# require. But debian's version of ruby-build, even in the latest bookworm, is old (2022).
27+
# Luckily rbenv basically uses ruby-build as a plugin. We remove apt's ruby-build then
28+
# install ruby-build from its main branch. That way all ruby versions are available.
29+
RUN apt remove -qy ruby-build && \
30+
git clone --branch v20231114 https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build && \
31+
"$(rbenv root)"/plugins/ruby-build/install.sh && \
32+
echo 'eval "$(rbenv init -)"' >> /root/.profile && \
33+
chmod 700 /root/.profile && \
34+
rm -rf /var/lib/apt/lists/*
35+
36+
# Ensure the rbenv init script in /root/.profile, added above, gets processed
37+
# before each RUN from now on, even though the bash shells are non-interactive.
38+
SHELL ["/bin/bash", "--login", "-c"]
39+
40+
RUN rbenv install $ruby_version && \
41+
rbenv global $ruby_version
42+
RUN gem install -v 2.4.22 bundler && \
43+
bundle config --local build.mysql2 -- $(ruby -r rbconfig -e 'puts RbConfig::CONFIG["configure_args"]' | xargs -n1 | grep with-openssl-dir)
44+
45+
ADD . ${WORKDIR}
46+
RUN bundle install

compose.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
services:
2+
app:
3+
build:
4+
dockerfile: Dockerfile
5+
args:
6+
- ruby_version=3.0.6
7+
- activerecord_version=6.1
8+
depends_on:
9+
- mysql
10+
- postgres
11+
mysql:
12+
platform: linux/amd64
13+
image: mysql:8-debian
14+
environment:
15+
- MYSQL_ROOT_PASSWORD=Password123
16+
volumes:
17+
- mysqldata:/var/lib/mysql
18+
postgres:
19+
image: postgres:15-alpine
20+
environment:
21+
- POSTGRES_PASSWORD=Password123
22+
volumes:
23+
- pgdata:/var/lib/postgresql/data
24+
volumes:
25+
mysqldata:
26+
pgdata:

0 commit comments

Comments
 (0)