Skip to content

Commit 4594ccd

Browse files
committed
got Docker working with my custom Ruby interpreter and backend
1 parent da7f22b commit 4594ccd

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

‎v4-cokapi/Dockerfile‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
# don't use 'latest' tag since that might change
1111
FROM ubuntu:14.04.1
1212
MAINTAINER Philip Guo <philip@pgbovine.net>
13+
14+
# if apt-get doesn't work, then follow these instructions:
15+
# http://stackoverflow.com/questions/24991136/docker-build-could-not-resolve-archive-ubuntu-com-apt-get-fails-to-install-a
16+
# Uncomment the following line in /etc/default/docker DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
17+
# Restart the Docker service sudo service docker restart
1318
RUN apt-get update && apt-get install -y \
1419
nodejs \
1520
openjdk-7-jdk \
@@ -43,3 +48,35 @@ COPY backends/java/run-java-backend.sh /tmp/
4348
RUN chmod a+x /tmp/run-java-backend.sh
4449

4550
RUN useradd netuser
51+
52+
53+
# Ruby backend: pretty complex setup since we need to compile and
54+
# install a custom Ruby interpreter
55+
56+
# lots of packages required to build ruby and to use the compiled version of 'gem'
57+
RUN apt-get update && apt-get install -y \
58+
build-essential \
59+
zlibc \
60+
zlib1g \
61+
zlib1g-dev \
62+
libssl-dev
63+
64+
RUN mkdir /tmp/ruby
65+
# automatically untars
66+
ADD backends/ruby/custom-ruby-interpreter/ruby-2.2.2.tar.gz /tmp/ruby
67+
ADD backends/ruby/custom-ruby-interpreter/altered-files /tmp/ruby/ruby-2.2.2
68+
RUN mkdir /tmp/ruby/ruby-2.2.2-custom-OPT/
69+
RUN cd /tmp/ruby/ruby-2.2.2 && ./configure --prefix=/tmp/ruby/ruby-2.2.2-custom-OPT/
70+
# beware takes a long time! so make sure we cache the build
71+
RUN cd /tmp/ruby/ruby-2.2.2 && make && make install
72+
# install custom gem
73+
RUN /tmp/ruby/ruby-2.2.2-custom-OPT/bin/gem install debug_inspector
74+
75+
COPY backends/ruby/pg_logger.rb /tmp/ruby/
76+
77+
# To properly run tests, become root:
78+
# $ docker run -t -i --rm --net=none --cap-drop all pgbovine/cokapi:v1 bash
79+
COPY backends/ruby/golden_test.py /tmp/ruby/
80+
RUN mkdir /tmp/ruby/tests
81+
ADD backends/ruby/tests /tmp/ruby/tests
82+
RUN cd /tmp/ruby && ln -s ruby-2.2.2-custom-OPT/bin/ruby

‎v4-cokapi/backends/ruby/custom-ruby-interpreter/README.txt‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ To build the custom Ruby interpreter - use ruby-2.2.2 in this directory:
44
tar -zxvf ruby-2.2.2.tar.gz
55
cp altered-files/* ruby-2.2.2/
66
cd ruby-2.2.2/
7-
mkdir $HOME/ruby-2.2.2-custom-OPT/
8-
./configure --prefix=$HOME/ruby-2.2.2-custom-OPT/
7+
mkdir ../ruby-2.2.2-custom-OPT/
8+
./configure --prefix=`pwd`/../ruby-2.2.2-custom-OPT/
99
make
1010
make install # don't forget this step!
1111

1212
To recompile, run:
1313
make install
1414

1515
To run the hacked Ruby, run binaries in:
16-
~/ruby-2.2.2-custom-OPT/bin/
16+
`pwd`/ruby-2.2.2-custom-OPT/bin/
1717

18-
The binding object should now have a new frame_id field
18+
The binding object should now have a new frame_id field, which
19+
../pg_logger.rb needs
1920

2021
e.g.,:
21-
~/ruby-2.2.2-custom-OPT/bin/ruby pg_logger.rb tests/recursive-fact.rb
22+
`pwd`/ruby-2.2.2-custom-OPT/bin/ruby pg_logger.rb tests/recursive-fact.rb
2223

0 commit comments

Comments
 (0)