Skip to content

Commit

Permalink
Fix Ruby YUM repo & allow dynamic users
Browse files Browse the repository at this point in the history
  • Loading branch information
marekjelen committed Feb 5, 2019
1 parent 5dcaeef commit def605d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ FROM centos
LABEL io.openshift.s2i.scripts-url="image:///usr/libexec/s2i" \
io.s2i.scripts-url="image:///usr/libexec/s2i"

RUN curl -sLf 'https://dl.cloudsmith.io/public/mjelen/mjelen/cfg/install/config.rpm.txt?os=el&dist=7' > /etc/yum.repos.d/mjelen-mjelen.repo && \
yum makecache -y && \
yum install --setopt=tsflags=nodocs -y ruby bundler \
RUN curl -sL -o /etc/yum.repos.d/centos-essentials.repo https://gist.githubusercontent.com/marekjelen/c08a3c3a548820144f2da01d2bad6279/raw/centos-essentials.repo
ENV PATH=/opt/essentials/bin:$PATH

RUN yum update -y && \
yum install --setopt=tsflags=nodocs -y essentials-ruby bundler \
gcc gcc-c++ libxml2-devel sqlite-devel git && \
yum clean all && \
rm -rf /var/cache/yum && \
gem update --system --no-document
rm -rf /var/cache/yum

RUN gem update --system --no-document && \
gem update bundler --no-document

RUN mkdir -p /usr/libexec/s2i

Expand All @@ -28,6 +32,7 @@ WORKDIR /workshopper

ADD --chown=workshopper:root Gemfile Gemfile.lock ./


RUN bundle install --deployment

ADD --chown=workshopper:root . .
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,3 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)

BUNDLED WITH
2.0.1
3 changes: 3 additions & 0 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def asset
end

def dashboard
end

def dump_sesssion
render json: session
end

end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
get '/workshop/:workshop/complete', to: 'welcome#complete'
get '/workshop/:workshop/asset/*path.:ext', to: 'welcome#asset'

get '/debug/session', to: 'welcome#dump_sesssion'

root 'welcome#index'

end
10 changes: 5 additions & 5 deletions lib/workshopper/lab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def env(workshop, session)
env[key] = session[key] if session[key]
end

if env['DYNAMIC_USER_NAME']
if ENV['DYNAMIC_USER_NAME']
@user_id ||= 0
if env['NUM_USERS'] && env['NUM_USERS'] > 0 && @user_id >= Integer(env['NUM_USERS'])
if ENV['NUM_USERS'] && Integer(ENV['NUM_USERS']) > 0 && @user_id >= Integer(ENV['NUM_USERS'])
raise Exception.new('Not enough users in workshop environment')
end
env['USER_NAME'] = 'dev%02d'
uid = session['user_id'] ||= (@user_id += 1)
env['USER_NAME'] = env['USER_NAME'] % uid
ENV['USER_NAME'] ||= 'user%d' #'user%02d'
uid = (session['user_id'] ||= (@user_id += 1))
env['USER_NAME'] = ENV['USER_NAME'] % uid
end

env
Expand Down

0 comments on commit def605d

Please sign in to comment.