-
Notifications
You must be signed in to change notification settings - Fork 29
/
Dockerfile
178 lines (152 loc) · 4.09 KB
/
Dockerfile
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
ARG BASE_IMAGE_TAG
ARG RUBY_VERSION
ARG RUBY_SO_SUFFIX
### build ###
FROM ubuntu:$BASE_IMAGE_TAG AS build
ARG BASE_IMAGE_TAG
ARG RUBY_VERSION
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
autoconf \
bison \
ca-certificates \
dpkg-dev \
gcc \
git \
g++ \
libffi-dev \
libgdbm-dev \
libgmp-dev \
libncurses5-dev \
libreadline-dev \
libssl-dev \
libyaml-dev \
make \
ruby \
rustc \
tzdata \
wget \
xz-utils \
zlib1g-dev \
&& \
apt-get clean && \
rm -r /var/lib/apt/lists/*
COPY tmp/ruby /usr/src/ruby
COPY install_ruby.sh /tmp/
RUN set -ex && \
RUBY_VERSION=3.2.3 PREFIX=/root /tmp/install_ruby.sh
RUN apt purge -y --auto-remove ruby
COPY tmp/ruby /usr/src/ruby
ARG optflags
ARG debugflags
ARG cppflags
RUN set -ex && \
# skip installing gem documentation
mkdir -p /usr/local/etc && \
{ \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc && \
\
PATH=/root/bin:$PATH /tmp/install_ruby.sh
### ruby ###
FROM ubuntu:$BASE_IMAGE_TAG AS ruby
ARG BASE_IMAGE_TAG
ARG RUBY_VERSION
ARG RUBY_SO_SUFFIX
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
libffi-dev \
libgdbm-dev \
libgmp-dev \
libncurses5-dev \
libreadline-dev \
libssl-dev \
libyaml-dev \
tzdata \
zlib1g-dev \
&& \
dpkg-query --show --showformat '${package}\n' \
| grep -P '^(lib(ffi|gdbm|gmp|ncurses|readline|ssl|yaml)|zlib)' \
| grep -v -P -- '-dev$' \
| xargs apt-mark manual \
&& \
apt-get purge -y --auto-remove \
libffi-dev \
libgdbm-dev \
libgmp-dev \
libncurses5-dev \
libreadline-dev \
libssl-dev \
libyaml-dev \
zlib1g-dev \
&& \
\
apt-get clean && rm -r /var/lib/apt/lists/*
RUN set -ex && \
if ! (id ubuntu &>/dev/null); then \
useradd -ms /bin/bash ubuntu; \
fi
RUN mkdir -p /usr/local/etc
COPY --from=build \
/usr/local/etc/gemrc /usr/local/etc
COPY --from=build \
/usr/local/bin/bundle \
/usr/local/bin/bundler \
/usr/local/bin/erb \
/usr/local/bin/gem \
/usr/local/bin/irb \
/usr/local/bin/racc \
/usr/local/bin/rake \
/usr/local/bin/rdoc \
/usr/local/bin/ri \
/usr/local/bin/ruby \
/usr/local/bin/
COPY --from=build \
/usr/local/etc/gemrc \
/usr/local/etc/
COPY --from=build \
/usr/local/include \
/usr/local/include
COPY --from=build \
/usr/local/lib/libruby.so.${RUBY_SO_SUFFIX:-$RUBY_VERSION} \
/usr/local/lib/
RUN set -ex && \
RUBY_SO_SUFFIX_MM=$(echo ${RUBY_SO_SUFFIX:-$RUBY_VERSION} | sed -e 's/\.[^.]\+$//') && \
ln -sf libruby.so.${RUBY_SO_SUFFIX:-$RUBY_VERSION} /usr/local/lib/libruby.so.${RUBY_SO_SUFFIX_MM} && \
ln -sf libruby.so.${RUBY_SO_SUFFIX:-$RUBY_VERSION} /usr/local/lib/libruby.so
COPY --from=build \
/usr/local/lib/pkgconfig/ \
/usr/local/lib/pkgconfig/
COPY --from=build \
/usr/local/lib/ruby/ \
/usr/local/lib/ruby/
COPY --from=build \
/usr/local/share/man/man1/erb.1 \
/usr/local/share/man/man1/irb.1 \
/usr/local/share/man/man1/ri.1 \
/usr/local/share/man/man1/ruby.1 \
/usr/local/share/man/man1/
### development ###
FROM ruby AS development
RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
curl \
gdb \
git \
less \
lv \
wget \
&& \
apt-get clean && \
rm -r /var/lib/apt/lists/*