Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #77 from xcthulhu/no-more-root
Browse files Browse the repository at this point in the history
No More Root
  • Loading branch information
jhoffner committed Aug 14, 2014
2 parents 21ff547 + 9516ffc commit f2417a9
Show file tree
Hide file tree
Showing 25 changed files with 457 additions and 427 deletions.
89 changes: 48 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@

# Pull base image.
FROM dockerfile/ubuntu

# Set the env variables to non-interactive
ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_PRIORITY critical
ENV DEBCONF_NOWARNINGS yes
ENV TERM linux
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

# ADD codewarrior user
RUN useradd codewarrior
RUN rm -rf ~codewarrior && cp -a ~root ~codewarrior && chown -R codewarrior:codewarrior ~codewarrior
RUN apt-get install -y python python-dev python-pip python-virtualenv

# Define mountable directories.

# Install Node.js
RUN \
cd /tmp && \
wget http://nodejs.org/dist/node-latest.tar.gz && \
tar xvzf node-latest.tar.gz && \
rm -f node-latest.tar.gz && \
cd node-v* && \
./configure && \
CXX="g++ -Wno-unused-local-typedefs" make && \
CXX="g++ -Wno-unused-local-typedefs" make install && \
cd /tmp && \
rm -rf /tmp/node-v* && \
echo '\n# Node.js\nexport PATH="node_modules/.bin:$PATH"' >> /root/.bash_profile

RUN add-apt-repository ppa:chris-lea/node.js
RUN apt-get update
RUN apt-get install -y nodejs
RUN su codewarrior -c "echo '\n# Node.js\nexport PATH=\"/codewars/node_modules/.bin:$PATH\"' >> ~codewarrior/.bash_profile"

# Define default command.
CMD ["bash"]
Expand All @@ -40,12 +42,8 @@ RUN apt-get install -y fsharp
# Install Coffeescript
RUN npm -g install coffee-script

# Install Node testing frameworks
RUN npm -g install chai
RUN npm -g install mocha

# Install additional node frameworks
RUN npm install immutable
# Install Node testing frameworks & additional frameworks
RUN npm -g install chai mocha immutable

# Install Lua
RUN apt-get install -y lua5.2
Expand All @@ -64,18 +62,14 @@ RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-s
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections
RUN apt-get install -y oracle-java8-installer

# Install Clojure
# Install Clojure (well, install Leiningen)
RUN curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > /usr/bin/lein
RUN chmod a+x /usr/bin/lein
# Add a few packages by default
RUN mkdir ~/.lein && echo '{:user {:dependencies [[org.clojure/clojure "1.6.0"] [junit/junit "4.11"] [org.hamcrest/hamcrest-core "1.3"]]}}' > ~/.lein/profiles.clj
RUN echo '(defproject codewars "Docker")' > project.clj
RUN LEIN_ROOT=true lein deps

# Install Haskell
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ghc cabal-install
RUN cabal update
RUN cabal install hspec
RUN apt-get install -y ghc cabal-install
RUN su codewarrior -c "cabal update"
RUN su codewarrior -c "cd ~codewarrior ; cabal install hspec"

# Install Julia
# Julia is really slow, but v0.3 is okay (see http://stackoverflow.com/a/20566032)
Expand All @@ -90,24 +84,26 @@ RUN printf '#!/bin/bash\njulia-noisy "$@" 2> >(grep -v "OpenBLAS : Your OS does
RUN chmod a+x /usr/bin/julia

# Install erlang
RUN apt-get -y install erlang
RUN echo "deb http://packages.erlang-solutions.com/ubuntu trusty contrib" >> /etc/apt/sources.list
RUN curl http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | apt-key add -
RUN apt-get update
RUN apt-get -y install erlang-nox erlang-dev

# Install PHP
RUN apt-get -y install php5-cli

# Install GoLang
WORKDIR /tmp
# http://blog.labix.org/2013/06/15/in-flight-deb-packages-of-go
RUN curl https://godeb.s3.amazonaws.com/godeb-amd64.tar.gz | tar zxv
RUN ./godeb install 1.3
RUN rm godeb
# This was cool but then it stopped working... that sucks... ~Matt
#RUN curl https://godeb.s3.amazonaws.com/godeb-amd64.tar.gz | tar zxv
#RUN ./godeb install 1.3.1
#RUN rm godeb
RUN apt-get install -y golang

# Install TypeScript
RUN npm -g install typescript

# Install Pip
RUN apt-get install python-pip

#Install ruby
RUN apt-get install -y python-software-properties && \
apt-add-repository -y ppa:brightbox/ruby-ng && \
Expand Down Expand Up @@ -135,23 +131,21 @@ RUN gem install rspec-its --no-ri --no-rdoc
#RUN gem install minitest --no-ri --no-rdoc

# Install additional gems

RUN gem install rails --no-ri --no-rdoc

# Install SQLITE
RUN apt-get install -y sqlite libsqlite3-dev

RUN gem install sqlite3 --no-ri --no-rdoc
RUN npm install sqlite3
RUN npm -g install sqlite3

# Install MongoDB
RUN apt-get install -y mongodb-server && \
mkdir /data && \
mkdir /data/db
mkdir -p /data/db && \
chown codewarrior:codewarrior /data/db

# Install mongo packages for languages
RUN npm install mongoose
RUN npm install mongodb
RUN npm -g install mongoose mongodb
RUN pip install pymongo
RUN gem install mongo --no-ri --no-rdoc
RUN gem install mongoid --no-ri --no-rdoc
Expand All @@ -160,7 +154,7 @@ RUN gem install mongoid --no-ri --no-rdoc
RUN apt-get install -y redis-server

# Install Redis Language packages
RUN npm install redis
RUN npm -g install redis
RUN gem install redis --no-ri --no-rdoc
RUN pip install redis

Expand All @@ -179,8 +173,21 @@ RUN apt-get -y install clang-3.4 lldb-3.4

# ADD cli-runner and install node deps
ADD . /codewars

# Build the jvm-runner
WORKDIR /codewars/jvm-runner
RUN [ -e target/jvm-runner-0.1.1-standalone.jar ] || LEIN_ROOT=true lein do clean, test, uberjar

WORKDIR /codewars
RUN npm install

# Run the test suite to make sure this thing works

USER codewarrior
# Set environment variables
ENV TIMEOUT 2000
ENV USER codewarrior
ENV HOME /home/codewarrior
RUN mocha -t 5000 test/*

#timeout is a fallback in case an error with node
Expand Down
79 changes: 0 additions & 79 deletions frameworks/clojure/clojure/test/codewars.clj

This file was deleted.

29 changes: 0 additions & 29 deletions frameworks/java/CwRunListener.java

This file was deleted.

11 changes: 0 additions & 11 deletions frameworks/java/CwTestRunner.java

This file was deleted.

7 changes: 4 additions & 3 deletions jvm-runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ RUN chmod a+x /usr/bin/lein
RUN LEIN_ROOT=true lein --version

# ADD codewarrior user
RUN useradd -s /usr/sbin/nologin codewarrior
RUN useradd -s /usr/sbin/nologin -m -d /home/codewarrior -p codewarrior codewarrior

# ADD cli-runner and install node deps
ADD . /codewars-jvm
WORKDIR /codewars-jvm
RUN LEIN_ROOT=true lein do clean, test, uberjar
RUN [ -e target/jvm-runner-0.1.1-standalone.jar ] || LEIN_ROOT=true lein do clean, test, uberjar

# Set the user and workdir
WORKDIR /tmp
USER codewarrior

# Run the uberjar
# TODO: Infer the version number for this somehow
ENV TIMEOUT 2000
ENV USER codewarrior
ENV HOME /home/codewarrior
ENTRYPOINT ["java", "-jar", "/codewars-jvm/target/jvm-runner-0.1.1-standalone.jar"]
2 changes: 1 addition & 1 deletion jvm-runner/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
:javac-target "1.8"
:dependencies [[org.clojure/clojure "1.6.0"]
[cheshire "5.3.1"]
[org.tcrawley/dynapath "0.2.3"]
[junit/junit "4.11"]
[org.codehaus.groovy/groovy-all "2.3.6"]
[environ "0.5.0"]]
:plugins [[lein-environ "0.5.0"]]
:source-paths ["src/clojure"]
Expand Down
14 changes: 9 additions & 5 deletions jvm-runner/src/clojure/codewars/core.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(ns codewars.core
(:require [cheshire.core :as json]
[codewars.runner :refer [run]]
[codewars.runners :refer [run]]
[codewars.kill-switch :refer [with-timeout]]
[environ.core :refer [env]]
[codewars.runner.java]
[codewars.runner.clojure])
[codewars.runners.groovy]
[codewars.runners.clojure]
[codewars.runners.java])
(:import [java.util.concurrent TimeoutException])
(:gen-class))

Expand All @@ -15,12 +16,15 @@
(defn- fail [e]
(binding [*out* *err*]
(println (str "<ERROR::>" (.getMessage e) "<:LF:>")))
(System/exit 1))
;(System/exit 1)
)

(defn -main
"Listens to *in* for a JSON message, parses it and calls the appropriate runner"
[& _]
(let [ms (-> env :timeout Integer/parseInt)
(let [ms ((fnil #(Integer/parseInt %)
"5000")
(env :timeout))
input (json/parse-stream *in* true)]
(try
(flush-out (with-timeout ms (run input)))
Expand Down
Loading

0 comments on commit f2417a9

Please sign in to comment.