Skip to content

Commit

Permalink
change base image to phusion/passenger-ruby23
Browse files Browse the repository at this point in the history
  • Loading branch information
qazbnm456 committed Jul 31, 2016
1 parent f187135 commit 213b8c6
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 45 deletions.
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
FROM phusion/passenger-ruby22
MAINTAINER Firmhouse "lobsiinvok@tdohacker.org"
FROM phusion/passenger-ruby23
MAINTAINER Boik Su "lobsiinvok@tdohacker.org"

ENV HOME /root
ENV RAILS_ENV production
RUN usermod -aG docker_env app
RUN echo unix:///tmp/docker.sock > /etc/container_environment/DOCKER_HOST

CMD ["/sbin/my_init"]

# https://forums.docker.com/t/using-docker-in-a-dockerized-jenkins-container/322/6
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y lxc \
&& apt-get install -y ruby2.3 ruby2.3-dev \
&& ruby-switch --set ruby2.3
&& apt-get install -y imagemagick libmagickwand-dev

WORKDIR /tmp
ADD Gemfile Gemfile
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<a name="notice"></a>

## Some notices you have to check out.
## Notice

Sometimes you may confront services looping forever, and this [link](http://stackoverflow.com/questions/11583562/how-to-kill-a-process-running-on-particular-port-in-linux) might helps you. Besides, if you wanna re-add the host, just delete the files in /var/lib/rancher/state.

Expand All @@ -39,7 +39,7 @@ Before using docker in Docker-War, [setup.sh](https://github.com/qazbnm456/Docke
* Ability to change challenges on-the-fly.
* Move [term.js](https://github.com/rancher/term.js) to [xterm.js](https://github.com/sourcelair/xterm.js).
* (Optional) Instant notifications built with WebSocket.
* (Optional) Change to SPA when Rails 5 releases.
* (Optional) Change to SPA.
* (Optional) Use [BTRFS](https://btrfs.wiki.kernel.org/index.php/Main_Page) or [ZFS](http://zfsonlinux.org) filesystem to storage images.
* (Optional) Importing the concept of [Continuous Deployment](http://rancher.com/continuous-deployment/).

Expand All @@ -49,8 +49,6 @@ Before using docker in Docker-War, [setup.sh](https://github.com/qazbnm456/Docke

* Git
* Docker, Compose, and Rancher Compose
* Protoc
* Node and Npm
* Mysql (or others)

<a name="setup"></a>
Expand All @@ -67,7 +65,7 @@ Before using docker in Docker-War, [setup.sh](https://github.com/qazbnm456/Docke

1. `$ sudo curl -fsSL https://get.docker.com/ | sh`
2. Verify if docker is installed correctly, `$ sudo docker run hello-world`
3. ``$ sudo curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose``
3. ``$ sudo curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose``
4. `$ sudo chmod +x /usr/local/bin/docker-compose`
5. Head for https://github.com/rancher/rancher-compose/releases, and download the one that compatible with your host environment. Don't forget to add it to $PATH.

Expand Down
19 changes: 0 additions & 19 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'diuitauth'
class PagesController < ApplicationController
before_action :authenticate_user!, only: [:chatroom, :wargame, :new_q, :qna_ans, :qna_edit, :qna_delete, :get_agent_details]
before_action :load_data, only: :timeline
before_action :disable_nav, only: :index
before_action :get_agent, :get_notice, :only => [:get_agent_details]

Expand Down Expand Up @@ -73,19 +72,6 @@ def completed_records
render json: ActiveRecord::Base.connection.execute('SELECT a.name, a.score FROM users AS a WHERE id != 1').chart_json
end

def timeline
Record.order(last_try_time: :desc).where('last_try_time > ?', @@time).find_each(:batch_size => 100) do |r|
if !r.last_try_time.nil?
@@data["timeline"]["date"] << { "startDate" => r.last_try_time.strftime("%Y,%m,%d,%H,%M,%S"), "headline" => "#{I18n.t("page_ranking.description", :name => r.user.name, :cate => r.cate, :solved => r.solved)}" }
#@@data["timeline"]["date"].inject({}) do |h, k|
#(h[k["timeline"]["date"]["startDate"]] ||= {}).merge!(k){ |key, old, new| old || new }
#h
#end.values
end
end
render json: @@data
end

def wargame
@basic_outlines = Basic.attributes
@web_outlines = Web.attributes
Expand Down Expand Up @@ -152,11 +138,6 @@ def get_agent_details
end

private
def load_data
@@data = { "timeline" => { "headline" => "#{I18n.t("page_ranking.live_submission")}", "type" => "default", "text" => "Docker-War", "date" => [] } }
@@time = DateTime.new(2014, 1, 1, 0, 0, 0)
end

def getToken
private_key = "#{ENV['DIUIT_PRIVATE_KEY']}"
exp = Time.now.utc.to_i + 4 * 3600
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
match '/rank', to: 'pages#rank', via: 'get'
match '/trend', to: 'pages#trend', via: 'get'
match '/completed_records', to: 'pages#completed_records', via: 'get'
match '/timeline', to: 'pages#timeline', via: 'get'
match '/get_agent_details', to: 'pages#get_agent_details', via: 'post'

match '/wargame/basic', to: 'basic#index', via: 'get'
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ wargame:
- /usr/bin/docker:/usr/bin/docker:ro
- /usr/bin/rancher-compose:/usr/bin/rancher-compose:ro
- /lib/x86_64-linux-gnu/libsystemd-journal.so.0:/lib/x86_64-linux-gnu/libsystemd-journal.so.0:ro
- /usr/bin/protoc:/usr/bin/protoc:ro
- /usr/bin/node:/usr/bin/node:ro
- /usr/bin/npm:/user/bin/npm:ro
environment:
- PD_DATABASE_HOST=$DB_HOST
- PD_DATABASE_USER=$DB_USER
Expand Down
6 changes: 3 additions & 3 deletions script/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# The Star And Thank Author License (SATA)
#
# Copyright (c) 2014-2016 Lobsiinvok (lobsiinvok@tdohacker.org)
# Copyright (c) 2014-2016 Boik Su (lobsiinvok@tdohacker.org)
#
# Project Url: https://github.com/qazbnm456/Docker-War
#
Expand Down Expand Up @@ -43,7 +43,7 @@
# #########################
set -e

PREREQUISITIES_IMAGES=(lobsiinvok_nginx-proxy richarvey/nginx-php-fpm lampe/minimal-nginx lobsiinvok_mysql)
PREREQUISITIES_IMAGES=(lobsiinvok_nginx-proxy richarvey/nginx-php-fpm lampe/minimal-nginx)

if docker version 2> /dev/null 1>&2; then
echo -e "\e[0;32m Docker works!\e[0m";
Expand Down Expand Up @@ -73,5 +73,5 @@ if docker version 2> /dev/null 1>&2; then
fi
done
else
echo -e "\e[0;31m Cannot find Docker\e[0m";
echo -e "\e[0;31m Docker not found!\e[0m";
fi
4 changes: 2 additions & 2 deletions script/playground.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# The Star And Thank Author License (SATA)
#
# Copyright (c) 2014-2016 Lobsiinvok (lobsiinvok@tdohacker.org)
# Copyright (c) 2014-2016 Boik Su (lobsiinvok@tdohacker.org)
#
# Project Url: https://github.com/qazbnm456/Docker-War
#
Expand Down Expand Up @@ -47,7 +47,7 @@ export RANCHER_SECRET_KEY=$RANCHER_SECRET_KEY
export DOMAIN=domain.com
export NGINX_PROXY=lobsiinvok_nginx-proxy
export VPS=ctf-tools
export SPAWNER=nsysu-wargame-spawner
export SPAWNER=wargame-spawner

while getopts "n:s:f:b:i:p:d" OPTION; do
case $OPTION in
Expand Down
4 changes: 1 addition & 3 deletions script/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# The Star And Thank Author License (SATA)
#
# Copyright (c) 2014-2016 Lobsiinvok (lobsiinvok@tdohacker.org)
# Copyright (c) 2014-2016 Boik Su (lobsiinvok@tdohacker.org)
#
# Project Url: https://github.com/qazbnm456/Docker-War
#
Expand Down Expand Up @@ -67,8 +67,6 @@ test -z ${secret} && echo "You MUST input a secret key." && exit 0
sed -i 's/domain.com/'${domain}'/g' playground.sh
sed -i 's/domain.com/'${domain}'/g' docker-compose.yml
sed -i 's/project_name/'${project}'/g' config.sh
sed -i 's/project_name/'${project}'/g' setup_sqlchop_proxy.sh
sed -i 's/domain.com/'${domain}'/g' setup_sqlchop_proxy.sh
sed -i 's/project_name/'${project}'/g' setup_lets_encrypt.sh
sed -i 's/domain.com/'${domain}'/g' setup_lets_encrypt.sh

Expand Down
5 changes: 2 additions & 3 deletions script/setup_lets_encrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# The Star And Thank Author License (SATA)
#
# Copyright (c) 2014-2016 Lobsiinvok (lobsiinvok@tdohacker.org)
# Copyright (c) 2014-2016 Boik Su (lobsiinvok@tdohacker.org)
#
# Project Url: https://github.com/qazbnm456/Docker-War
#
Expand Down Expand Up @@ -61,5 +61,4 @@ cd $PWD \
&& echo "Enable the https endpoint" \
&& ln -s /etc/nginx/sites-available/https_nginx.conf /etc/nginx/sites-enabled/https_nginx.conf \
&& echo "Reload nginx service..." \
&& service nginx reload \
&& /home/app/project_name/script/setup_sqlchop_proxy.sh &
&& service nginx reload &
2 changes: 1 addition & 1 deletion script/setup_sqlchop_proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# The Star And Thank Author License (SATA)
#
# Copyright (c) 2014-2016 Lobsiinvok (lobsiinvok@tdohacker.org)
# Copyright (c) 2014-2016 Boik Su (lobsiinvok@tdohacker.org)
#
# Project Url: https://github.com/qazbnm456/Docker-War
#
Expand Down

0 comments on commit 213b8c6

Please sign in to comment.