-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile
101 lines (94 loc) · 3.71 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
FROM --platform=linux/amd64 heroku/heroku:22-build
LABEL maintainer="[email protected]"
ENV HOME=/app \
HEROKU_HOME=/heroku \
HEROKU_BUILDPACK_VERSION=22 \
# The versions are updated according to Heroku Ruby Buildpack
# Check this file for RUBY version:
# https://github.com/heroku/heroku-buildpack-ruby/blob/main/lib/language_pack/ruby_version.rb#L16
RUBY_VERSION=3.1.4 \
# Check this file for NODE version:
# https://github.com/heroku/heroku-buildpack-ruby/blob/main/lib/language_pack/helpers/nodebin.rb#L5
NODE_VERSION=20.9.0 \
# Check this file for YARN version:
# https://github.com/heroku/heroku-buildpack-ruby/blob/main/lib/language_pack/helpers/nodebin.rb#L13
YARN_VERSION=1.22.19
ENV PATH=$HOME/bin:$HEROKU_HOME/ruby/bundle/ruby/$RUBY_VERSION/bin:$HEROKU_HOME/ruby/ruby-$RUBY_VERSION/bin:$HEROKU_HOME/ruby/node-$NODE_VERSION/bin:$HEROKU_HOME/ruby/yarn-$YARN_VERSION/bin:${PATH} \
# so no interactions happen while installing packages
DEBIAN_FRONTEND=noninteractive \
# Bundler variables
GEM_PATH=$HEROKU_HOME/ruby/bundle/ruby/$RUBY_VERSION \
GEM_HOME=$HEROKU_HOME/ruby/bundle/ruby/$RUBY_VERSION \
BUNDLE_APP_CONFIG=$HEROKU_HOME/ruby/.bundle/config
# set the locale of the application
# this is useful for rails console handling UTF8 characters
ARG LOCALE="en_US.UTF-8"
ENV LANG=$LOCALE \
LC_COLLATE=$LOCALE \
LC_CTYPE=$LOCALE \
LC_MESSAGES=$LOCALE \
LC_MONETARY=$LOCALE \
LC_NUMERIC=$LOCALE \
LC_TIME=$LOCALE \
LC_ALL=$LOCALE
# Copy init script
COPY ./init.sh /usr/bin/init.sh
RUN set -ex ;\
export ARCH=$(dpkg --print-architecture) ;\
mkdir -p $HOME ;\
#------------
# Remove existing ruby
#------------
dpkg --purge --force-depends ruby ;\
#------------
# Install extra dependencies
#------------
apt-get update && apt-get install -y --no-install-recommends \
tzdata \
tree \
# needed to download https gems
libssl-dev \
# for rails rspec
busybox \
# utils
inetutils-ping \
vim \
; \
rm -rf /var/lib/apt/lists/* ;\
# fix bug when launching rails console
ln -s /lib/x86_64-linux-gnu/libreadline.so.7 /lib/x86_64-linux-gnu/libreadline.so.6 ;\
#------------
# Install Ruby
#------------
mkdir -p $HEROKU_HOME/ruby/ruby-$RUBY_VERSION ;\
curl -sL --retry 3 https://heroku-buildpack-ruby.s3.amazonaws.com/heroku-$HEROKU_BUILDPACK_VERSION/ruby-$RUBY_VERSION.tgz | tar xz -C $HEROKU_HOME/ruby/ruby-$RUBY_VERSION ;\
#------------
# Install Node
#------------
# node archictures has different matches -- this just covers our 2 platforms (arm64 and amd64)
case "$ARCH" in \
amd64) NODE_ARCH='x64' ;;\
*) NODE_ARCH="$ARCH" ;;\
esac ;\
curl -sL --retry 3 https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$NODE_ARCH.tar.xz | tar xJ -C $HEROKU_HOME/ruby/ ;\
mv $HEROKU_HOME/ruby/node-v$NODE_VERSION-linux-$NODE_ARCH $HEROKU_HOME/ruby/node-$NODE_VERSION ;\
#------------
# Install Yarn
#------------
curl -sL --retry 3 https://s3.amazonaws.com/heroku-nodebin/yarn/release/yarn-v$YARN_VERSION.tar.gz | tar xz -C $HEROKU_HOME/ruby/ ;\
mv $HEROKU_HOME/ruby/yarn-v$YARN_VERSION $HEROKU_HOME/ruby/yarn-$YARN_VERSION ;\
#------------
# Set startup script
#------------
chmod +x /usr/bin/init.sh
#------------
# Install application and its gems
#------------
WORKDIR $HOME
ONBUILD ADD . $HOME
ONBUILD RUN set -ex ;\
# force bundle to use github https protocol
bundle config github.https true
# avoid installing gems here so we give a chance for child images to install any dependency
# eg. SQLite3 extension
ENTRYPOINT ["/usr/bin/init.sh"]