From 9c60b76f2552d78ae20f7e847137c46be53ed0d9 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 3 Nov 2017 19:43:56 +0000 Subject: [PATCH] first commit --- Dockerfile | 43 ++++++++++++++++++++++++++++++++ docker/entrypoint | 28 +++++++++++++++++++++ docker/nginx.conf | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 Dockerfile create mode 100755 docker/entrypoint create mode 100644 docker/nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7e85262 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM node:6-alpine + +RUN mkdir -p /usr/local/etc \ + && { \ + echo 'install: --no-document'; \ + echo 'update: --no-document'; \ +} >> /usr/local/etc/gemrc \ + && apk -U upgrade \ + && apk add -t build-dependencies \ + git \ + curl-dev \ + wget \ + ruby-dev \ + zlib-dev \ + build-base \ + mariadb-dev \ + && apk add ruby ruby-io-console ruby-json ruby-bigdecimal zlib tzdata mariadb-client-libs \ + && gem install -N rails --version "$RAILS_VERSION" \ + && echo 'gem: --no-document' >> ~/.gemrc \ + && cp ~/.gemrc /etc/gemrc \ + && chmod uog+r /etc/gemrc \ + && npm install -g bower \ + && rm -rf ~/.gem \ + && git clone https://github.com/standardfile/ruby-server.git standardfile \ + && cd standardfile \ + && rm -rf .git/ \ + && gem install bigdecimal \ + && echo "bundle install" \ + && bundle config --global silence_root_warning 1 \ + && bundle install --system \ + && echo "bower install" \ + && bower install --allow-root \ + && apk del build-dependencies \ + && rm -rf /tmp/* /var/cache/apk/* /tmp/* /root/.gnupg /root/.cache/ \ + && echo "bundle precompile" \ + && bundle exec rake assets:precompile + +EXPOSE 3000 + +COPY /docker /docker + +ENTRYPOINT [ "/docker/entrypoint" ] +CMD [ "start" ] diff --git a/docker/entrypoint b/docker/entrypoint new file mode 100755 index 0000000..6076652 --- /dev/null +++ b/docker/entrypoint @@ -0,0 +1,28 @@ +#!/usr/bin/env sh +# $0 is a script name, +# $1, $2, $3 etc are passed arguments +# $1 is our command +CMD=$1 + +case "$CMD" in + 'start' ) + echo `pwd` + rm -f /data/src/tmp/pids/server.pid + cd /standardfile/ + bundle exec rails db:create db:migrate + bundle install + bower install --allow-root + bundle exec rails s -b 0.0.0.0 + ;; + + 'bootstrap' ) + cd /standardfile/ + bundle exec rails db:create db:migrate + ;; + + * ) + # Run custom command. Thanks to this line we can still use + # "docker run our_image /bin/bash" and it will work + exec "$@" + ;; +esac diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..170eae3 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,63 @@ +upstream puma_sample_rails_docker_app { + server app:3000; +} + +server { + + listen 80; + + client_max_body_size 4G; + keepalive_timeout 10; + + error_page 500 502 504 /500.html; + error_page 503 @503; + + server_name localhost puma_sample_rails_docker_app; + root /data/src/public; + try_files $uri/index.html $uri @puma_sample_rails_docker_app; + + location @puma_sample_rails_docker_app { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + + proxy_pass http://puma_sample_rails_docker_app; + # limit_req zone=one; + access_log /data/src/log/nginx.access.log; + error_log /data/src/log/nginx.error.log; + } + + location ^~ /assets/ { + gzip_static on; + expires max; + add_header Cache-Control public; + } + + location = /50x.html { + root html; + } + + location = /404.html { + root html; + } + + location @503 { + error_page 405 = /system/maintenance.html; + if (-f $document_root/system/maintenance.html) { + rewrite ^(.*)$ /system/maintenance.html break; + } + rewrite ^(.*)$ /503.html break; + } + + if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)$ ){ + return 405; + } + + if (-f $document_root/system/maintenance.html) { + return 503; + } + + location ~ \.(php|html)$ { + return 405; + } +}