Browse Source

Dockerization

new-scoring
aeris 1 year ago
parent
commit
07857d4bb8
3 changed files with 81 additions and 10 deletions
  1. 8
    0
      .dockerignore
  2. 42
    0
      Dockerfile
  3. 31
    10
      Makefile

+ 8
- 0
.dockerignore View File

@@ -0,0 +1,8 @@
1
+Dockerfile
2
+.git/*
3
+build/*
4
+tmp/*
5
+log/*
6
+output/*
7
+lib/*.so
8
+lib/*.so.*

+ 42
- 0
Dockerfile View File

@@ -0,0 +1,42 @@
1
+FROM alpine:3.7 AS builder
2
+MAINTAINER aeris <aeris@imirhil.fr>
3
+
4
+RUN apk add --update make gcc \
5
+	linux-headers readline-dev libxml2-dev yaml-dev zlib-dev libffi-dev gdbm-dev ncurses-dev \
6
+	ca-certificates wget patch perl musl-dev bash coreutils git
7
+
8
+ENV LD_LIBRARY_PATH /usr/local/ssl/lib
9
+
10
+WORKDIR /cryptcheck/
11
+COPY . /cryptcheck/
12
+
13
+RUN make install-openssl
14
+RUN PATH=/usr/local/ssl/bin:$PATH \
15
+	LIBRARY_PATH=$LD_LIBRARY_PATH \
16
+	C_INCLUDE_PATH=/usr/local/ssl/include \
17
+	ac_cv_func_isnan=yes ac_cv_func_isinf=yes \
18
+	make install-ruby && \
19
+	make mr-proper
20
+RUN echo "gem: --no-test --no-document" > /etc/gemrc && \
21
+	gem install bundler && \
22
+	bundle install --deployment --without development test
23
+
24
+FROM alpine:3.7 AS engine
25
+MAINTAINER aeris <aeris@imirhil.fr>
26
+
27
+WORKDIR /cryptcheck/
28
+RUN apk add --update bash ca-certificates libxml2 yaml zlib libffi gdbm ncurses
29
+ENV LD_LIBRARY_PATH /usr/local/ssl/lib/
30
+
31
+COPY --from=builder /etc/gemrc /etc/gemrc
32
+COPY --from=builder /usr/local/ssl/ /usr/local/ssl/
33
+COPY --from=builder /usr/local/include/ruby-2.3.0/ /usr/local/include/ruby-2.3.0/
34
+COPY --from=builder /usr/local/bin/bundle \
35
+					/usr/local/bin/bundler\
36
+					/usr/local/bin/gem \
37
+					/usr/local/bin/rake \
38
+					/usr/local/bin/ruby \
39
+					/usr/local/bin/
40
+COPY --from=builder /usr/local/lib/libruby* /usr/local/lib/
41
+COPY --from=builder /usr/local/lib/ruby/ /usr/local/lib/ruby/
42
+COPY --from=builder /cryptcheck/ /cryptcheck/

+ 31
- 10
Makefile View File

@@ -11,11 +11,12 @@ RUBY_OPENSSL_EXT_DIR = $(RUBY_DIR)/ext/openssl
11 11
 RBENV_DIR = $(RBENV_ROOT)/versions/$(RUBY_VERSION)-cryptcheck
12 12
 RUBY_LIB_DIR = $(RBENV_DIR)/lib/ruby/$(RUBY_MAJOR_VERSION).0
13 13
 RBENV_ROOT ?= ~/.rbenv
14
-export LIBRARY_PATH = $(PWD)/lib
15
-export C_INCLUDE_PATH = $(PWD)/$(OPENSSL_DIR)/include
16
-export LD_LIBRARY_PATH = $(PWD)/lib
14
+export LIBRARY_PATH ?= $(PWD)/lib
15
+export C_INCLUDE_PATH ?= $(PWD)/$(OPENSSL_DIR)/include
16
+export LD_LIBRARY_PATH ?= $(PWD)/lib
17 17
 
18 18
 .SECONDARY:
19
+.SUFFIXES:
19 20
 
20 21
 all: libs ext
21 22
 
@@ -56,6 +57,9 @@ $(OPENSSL_DIR)/libssl.so \
56 57
 $(OPENSSL_DIR)/libcrypto.so: $(OPENSSL_DIR)/Makefile
57 58
 	$(MAKE) -C $(OPENSSL_DIR)
58 59
 
60
+install-openssl: $(OPENSSL_DIR)/Makefile
61
+	$(MAKE) -C $(OPENSSL_DIR) install
62
+
59 63
 LIBS = lib/libssl.so lib/libcrypto.so lib/libssl.so.$(OPENSSL_LIB_VERSION) lib/libcrypto.so.$(OPENSSL_LIB_VERSION)
60 64
 lib/%.so: $(OPENSSL_DIR)/%.so
61 65
 	cp $< $@
@@ -63,21 +67,35 @@ lib/%.so.$(OPENSSL_LIB_VERSION): lib/%.so
63 67
 	ln -fs $(notdir $(subst .$(OPENSSL_LIB_VERSION),,$@)) $@
64 68
 libs: $(LIBS)
65 69
 
70
+$(RBENV_ROOT)/:
71
+	git clone https://github.com/rbenv/rbenv/ $@ -b v1.1.1 --depth 1
72
+
73
+$(RBENV_ROOT)/plugins/ruby-build/: | $(RBENV_ROOT)/
74
+	git clone https://github.com/rbenv/ruby-build/ $@ -b v20171215 --depth 1
75
+
76
+$(RBENV_ROOT)/plugins/ruby-build/share/ruby-build/$(RUBY_VERSION): | $(RBENV_ROOT)/plugins/ruby-build/
77
+
66 78
 build/$(RUBY_VERSION)-cryptcheck: $(RBENV_ROOT)/plugins/ruby-build/share/ruby-build/$(RUBY_VERSION)
67 79
 	cp $< $@
68
-install-ruby: build/$(RUBY_VERSION)-cryptcheck $(LIBS) | $(OPENSSL_DIR)/
80
+
81
+install-rbenv: build/$(RUBY_VERSION)-cryptcheck
82
+
83
+install-rbenv-cryptcheck: build/$(RUBY_VERSION)-cryptcheck $(LIBS) | $(OPENSSL_DIR)/
69 84
 	cat tmp_key.patch set_ecdh_curves.patch fallback_scsv.patch multiple_certs.patch | \
70 85
 	RUBY_BUILD_CACHE_PATH=$(PWD)/build \
71 86
 	RUBY_BUILD_DEFINITIONS=$(PWD)/build \
72 87
 	rbenv install -fp $(RUBY_VERSION)-cryptcheck
73
-	rbenv sequester $(RUBY_VERSION)-cryptcheck
88
+	# rbenv sequester $(RUBY_VERSION)-cryptcheck
74 89
 	rbenv local $(RUBY_VERSION)-cryptcheck
75 90
 	gem install bundler
76
-	bundle
91
+	bundle install --without test development
92
+
77 93
 $(RUBY_LIB_DIR)/openssl/ssl.rb: $(RUBY_OPENSSL_EXT_DIR)/lib/openssl/ssl.rb
78 94
 	cp $< $@
95
+
79 96
 $(RUBY_LIB_DIR)/x86_64-linux/openssl.so: $(RUBY_OPENSSL_EXT_DIR)/openssl.so
80 97
 	cp $< $@
98
+
81 99
 sync-ruby: $(RUBY_LIB_DIR)/openssl/ssl.rb $(RUBY_LIB_DIR)/x86_64-linux/openssl.so
82 100
 
83 101
 build/$(RUBY_NAME).tar.xz: | build/
@@ -85,12 +103,12 @@ build/$(RUBY_NAME).tar.xz: | build/
85 103
 
86 104
 $(RUBY_DIR)/: build/$(RUBY_NAME).tar.xz
87 105
 	tar -C build -xf $<
106
+	patch -d $@ -p1 < tmp_key.patch
107
+	patch -d $@ -p1 < set_ecdh_curves.patch
108
+	patch -d $@ -p1 < fallback_scsv.patch
109
+	patch -d $@ -p1 < multiple_certs.patch
88 110
 
89 111
 $(RUBY_OPENSSL_EXT_DIR)/Makefile: libs | $(RUBY_DIR)/
90
-	patch -d $(RUBY_DIR)/ -p1 < tmp_key.patch
91
-	patch -d $(RUBY_DIR)/ -p1 < set_ecdh_curves.patch
92
-	patch -d $(RUBY_DIR)/ -p1 < fallback_scsv.patch
93
-	patch -d $(RUBY_DIR)/ -p1 < multiple_certs.patch
94 112
 	cd $(RUBY_OPENSSL_EXT_DIR) && ruby extconf.rb
95 113
 
96 114
 $(RUBY_OPENSSL_EXT_DIR)/openssl.so: $(LIBS) $(RUBY_OPENSSL_EXT_DIR)/Makefile
@@ -101,6 +119,9 @@ lib/openssl.so: $(RUBY_OPENSSL_EXT_DIR)/openssl.so
101 119
 
102 120
 ext: lib/openssl.so
103 121
 
122
+install-ruby: $(RUBY_DIR)/
123
+	cd $(RUBY_DIR)/ && ./configure --enable-shared --disable-install-rdoc && make install
124
+
104 125
 spec/faketime/libfaketime.so: spec/faketime/faketime.c spec/faketime/faketime.h
105 126
 	$(CC) $^ -o $@ -shared -fPIC -ldl -std=c99 -Werror -Wall
106 127
 lib/libfaketime.so: spec/faketime/libfaketime.so

Loading…
Cancel
Save