-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM http-garden-soil:latest | ||
|
||
RUN apt -y update && apt -y upgrade && apt -y install ruby-dev ragel && gem install raindrops kgio olddoc rack sleepy_penguin kcar | ||
|
||
ARG PARSER_REPO | ||
RUN git clone --recurse-submodules "$PARSER_REPO" | ||
|
||
ARG PARSER_VERSION | ||
RUN cd /app/unicorn && git pull && git checkout "$PARSER_VERSION" && export LC_ALL=C.UTF-8 && make -j$(nproc) install-gem | ||
|
||
ARG APP_REPO | ||
RUN git clone --recurse-submodules "$APP_REPO" | ||
|
||
ARG APP_VERSION | ||
COPY patch.diff . | ||
RUN cd /app/yahns && git pull && git apply /app/patch.diff && git checkout "$APP_VERSION" && make install-gem | ||
|
||
COPY yahns.conf . | ||
|
||
ARG CONFIG_FILE | ||
COPY $CONFIG_FILE ./config.ru | ||
ARG BACKEND | ||
RUN sed -i "s/PROXY_BACKEND_PLACEHOLDER/$BACKEND/g" config.ru | ||
|
||
CMD ["yahns", "-c", "yahns.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb | ||
index 826eb8d..5b40018 100644 | ||
--- a/lib/yahns/http_client.rb | ||
+++ b/lib/yahns/http_client.rb | ||
@@ -8,6 +8,8 @@ | ||
rescue LoadError | ||
end | ||
|
||
+require 'kgio' | ||
+ | ||
class Yahns::HttpClient < Kgio::Socket # :nodoc: | ||
NULL_IO = StringIO.new(''.dup) # :nodoc: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'yahns/proxy_pass' | ||
run Yahns::ProxyPass.new('http://PROXY_BACKEND_PLACEHOLDER') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'json' | ||
require 'base64' | ||
|
||
class Server | ||
def call(env) | ||
result = {} | ||
result['headers'] = [] | ||
env.each do |key, value| | ||
if not ["QUERY_STRING", "REQUEST_METHOD", "REQUEST_PATH", "PATH_INFO", "REQUEST_URI", "SERVER_PROTOCOL", "HTTP_VERSION", "rack.url_scheme", "SERVER_NAME", "SERVER_PORT", "REMOTE_ADDR", "rack.hijack", "rack.input", "rack.errors", "rack.multiprocess", "rack.multithread", "rack.run_once", "rack.hijack?", "rack.version", "SCRIPT_NAME", "SERVER_SOFTWARE", "rack.logger", "rack.tempfiles"].include?(key) | ||
result['headers'].push([Base64.encode64(key.sub(/\AHTTP_/, "")).strip(), Base64.encode64(value).strip()]) | ||
end | ||
end | ||
result['method'] = Base64.encode64(env["REQUEST_METHOD"]).strip() | ||
result['uri'] = Base64.encode64(env["REQUEST_URI"]).strip() | ||
result['body'] = Base64.encode64(env["rack.input"].read).strip() | ||
result['version'] = Base64.encode64(env["SERVER_PROTOCOL"]).strip() | ||
[200, {}, [result.to_json]] | ||
end | ||
end | ||
|
||
run Server.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
app(:rack, "/app/config.ru", preload: true) do | ||
listen 80 | ||
end |