-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (79 loc) · 2.47 KB
/
Dockerfile
File metadata and controls
92 lines (79 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Ruby Butler Integration Test Environment
#
# Multi-stage build for parallel Ruby compilation and optimized caching
# Base stage with common dependencies
FROM debian:trixie-slim AS base
# Install system dependencies (cached layer)
RUN apt-get update && apt-get install -y \
curl \
build-essential \
git \
libssl-dev \
libreadline-dev \
zlib1g-dev \
libncurses5-dev \
libffi-dev \
libgdbm-dev \
libyaml-dev \
libsqlite3-dev \
libtool \
bison \
pkg-config \
autoconf \
autotools-dev \
automake \
libbz2-dev \
ca-certificates \
libjemalloc-dev \
parallel \
&& rm -rf /var/lib/apt/lists/*
# Install ruby-install once (cached layer)
RUN curl -fsSL https://github.com/postmodern/ruby-install/releases/download/v0.10.1/ruby-install-0.10.1.tar.gz | tar -xzf - \
&& cd ruby-install-0.10.1 \
&& make install \
&& cd .. \
&& rm -rf ruby-install-0.10.1
# Stage for Ruby 4.0.1 compilation
FROM base AS ruby-4-0-1
RUN mkdir -p /opt/rubies && \
MAKE_OPTS="-j$(nproc)" \
ruby-install \
--install-dir /opt/rubies/ruby-4.0.1 \
--jobs $(nproc) \
--cleanup \
ruby 4.0.1 \
-- --with-jemalloc \
&& /opt/rubies/ruby-4.0.1/bin/gem install bundler --no-document
# Stage for Ruby 3.4.5 compilation
FROM base AS ruby-3-4-5
RUN mkdir -p /opt/rubies && \
MAKE_OPTS="-j$(nproc)" \
ruby-install \
--install-dir /opt/rubies/ruby-3.4.5 \
--jobs $(nproc) \
--cleanup \
ruby 3.4.5 \
-- --with-jemalloc \
&& /opt/rubies/ruby-3.4.5/bin/gem install bundler --no-document
# Final stage - copy compiled Rubies
FROM base AS final
# Install ShellSpec (modern shell testing framework)
RUN git clone https://github.com/shellspec/shellspec.git /tmp/shellspec \
&& cd /tmp/shellspec \
&& make install PREFIX=/usr/local \
&& rm -rf /tmp/shellspec
# Copy compiled Ruby installations from parallel stages
COPY --from=ruby-4-0-1 /opt/rubies/ruby-4.0.1 /opt/rubies/ruby-4.0.1
COPY --from=ruby-3-4-5 /opt/rubies/ruby-3.4.5 /opt/rubies/ruby-3.4.5
# Create test user (non-root for realistic testing)
RUN useradd -m -s /bin/bash testuser \
&& mkdir -p /home/testuser/.gem \
&& chown -R testuser:testuser /home/testuser \
&& mkdir -p /app \
&& chown -R testuser:testuser /app \
&& mkdir -p /app/report \
&& chown -R testuser:testuser /app/report
# Set up working directory
WORKDIR /app
# Switch to test user
USER testuser