diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8cb6361 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +sudo: required +language: ruby +services: + - docker +script: rake diff --git a/Dockerfile b/Dockerfile index 6d8690f..79b7e57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,27 @@ # # Dockerfile # -# Author: Matteo Cerutti -# - FROM centos:7 -MAINTAINER Matteo Cerutti +MAINTAINER Krzysztof SuszyƄski ENV PUPPET_FORGE_SERVER_USER forge ENV PUPPET_FORGE_SERVER_USER_ID 576 -ENV PUPPET_FORGE_SERVER_RACK puma -ENV PUPPET_FORGE_SERVER_VERSION '-v 1.8.0' ENV PUPPET_FORGE_SERVER_BASEDIR /srv/puppet-forge-server -RUN yum install gcc make ruby-devel rubygems -y +RUN yum install gcc make ruby-devel -y # Needed to fetch dependencies RUN echo ':ssl_verify_mode: 0' > ~/.gemrc -RUN gem install puppet-forge-server $PUPPET_FORGE_SERVER_VERSION -RUN gem install $PUPPET_FORGE_SERVER_RACK +RUN gem install bundler RUN useradd --system --create-home --uid $PUPPET_FORGE_SERVER_USER_ID --home-dir $PUPPET_FORGE_SERVER_BASEDIR $PUPPET_FORGE_SERVER_USER -ADD run.sh /run.sh +COPY src/Gemfile Gemfile +COPY src/Gemfile.lock Gemfile.lock +RUN bundle --retry=3 WORKDIR $PUPPET_FORGE_SERVER_BASEDIR USER $PUPPET_FORGE_SERVER_USER + +COPY src/run.sh /run.sh + ENTRYPOINT ["/run.sh"] diff --git a/README.md b/README.md index 383f674..7b41a48 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,6 @@ docker run -d --restart=always -p 8080:8080 \ ``` ## Contact -Matteo Cerutti - matteo.cerutti@hotmail.co.uk +Centralny Osrodek Informatyki - coi@coi.gov.pl + +Original version created by Matteo Cerutti - matteo.cerutti@hotmail.co.uk diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..4647ce5 --- /dev/null +++ b/Rakefile @@ -0,0 +1,13 @@ + +desc 'Cleans produced image' +task :clean do + sh 'docker rmi -f coigovpl/puppet-forge-server || true' + sh 'docker images -q --filter "dangling=true" | xargs docker rmi || true' +end + +desc 'Builds an image' +task :build do + sh 'docker build -t coigovpl/puppet-forge-server .' +end + +task :default => [:clean, :build] diff --git a/src/Gemfile b/src/Gemfile new file mode 100644 index 0000000..edd0a54 --- /dev/null +++ b/src/Gemfile @@ -0,0 +1,7 @@ +source 'https://rubygems.org' + +# Lock Ruby version to default centos-7 +ruby '~> 2.0.0' + +gem 'puppet-forge-server' +gem 'puma' diff --git a/src/Gemfile.lock b/src/Gemfile.lock new file mode 100644 index 0000000..99db0c9 --- /dev/null +++ b/src/Gemfile.lock @@ -0,0 +1,66 @@ +GEM + remote: https://rubygems.org/ + specs: + PriorityQueue (0.1.2) + backports (3.11.1) + deep_merge (1.2.1) + haml (4.0.7) + tilt + iconv (1.0.5) + json (1.8.6) + logger-colors (1.0.0) + lrucache (0.1.4) + PriorityQueue (~> 0.1.2) + multi_json (1.13.1) + multipart-post (2.0.0) + open4 (1.3.4) + open_uri_redirections (0.2.1) + puma (3.11.2) + puppet-forge-server (1.10.1) + deep_merge (~> 1.0) + haml (~> 4.0) + iconv (~> 1.0.4) + json (~> 1.8) + logger-colors (~> 1.0) + lrucache (~> 0.1.4) + multipart-post (~> 2.0.0) + open4 (~> 1.3) + open_uri_redirections (~> 0.1) + rack (= 1.5.5) + rack-mount (~> 0.8) + redcarpet (~> 3.3.0) + sinatra (~> 1.4) + sinatra-contrib (~> 1.4) + rack (1.5.5) + rack-mount (0.8.3) + rack (>= 1.0.0) + rack-protection (1.5.3) + rack + rack-test (0.7.0) + rack (>= 1.0, < 3) + redcarpet (3.3.4) + sinatra (1.4.8) + rack (~> 1.5) + rack-protection (~> 1.4) + tilt (>= 1.3, < 3) + sinatra-contrib (1.4.7) + backports (>= 2.0) + multi_json + rack-protection + rack-test + sinatra (~> 1.4.0) + tilt (>= 1.3, < 3) + tilt (2.0.8) + +PLATFORMS + ruby + +DEPENDENCIES + puma + puppet-forge-server + +RUBY VERSION + ruby 2.0.0p648 + +BUNDLED WITH + 1.16.1 diff --git a/run.sh b/src/run.sh similarity index 82% rename from run.sh rename to src/run.sh index 42fc7b7..29fb98b 100755 --- a/run.sh +++ b/src/run.sh @@ -5,6 +5,8 @@ # Author: Matteo Cerutti # +PUPPET_FORGE_SERVER_CACHE_SIZE=${PUPPET_FORGE_SERVER_CACHE_SIZE:-250} +PUPPET_FORGE_SERVER_CACHE_TTL=${PUPPET_FORGE_SERVER_CACHE_TTL:-1800} PUPPET_FORGE_SERVER_PORT=${PUPPET_FORGE_SERVER_PORT:-8080} PUPPET_FORGE_SERVER_USER=${PUPPET_FORGE_SERVER_USER:-$(whoami)} homedir=$( getent passwd "${PUPPET_FORGE_SERVER_USER}" | cut -d: -f6 ) @@ -33,8 +35,10 @@ mkdir -p $PUPPET_FORGE_SERVER_CACHE_DIR mkdir -p $PUPPET_FORGE_SERVER_LOG_DIR echo "Starting puppet-forge-server" -exec puppet-forge-server \ +exec bundle exec puppet-forge-server \ --port $PUPPET_FORGE_SERVER_PORT \ --cache-basedir $PUPPET_FORGE_SERVER_CACHE_DIR \ + --ram-cache-ttl $PUPPET_FORGE_SERVER_CACHE_TTL \ + --ram-cache-size $PUPPET_FORGE_SERVER_CACHE_SIZE \ --log-dir $PUPPET_FORGE_SERVER_LOG_DIR \ $PUPPET_FORGE_SERVER_OPTS