mirror of https://github.com/codevalet/codevalet
Merge pull request #80 from rtyler/79
Store sessions in memcached and support replicas for the webapp
This commit is contained in:
commit
68b1cfae24
|
@ -2,6 +2,18 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
webapp:
|
webapp:
|
||||||
image: 'rtyler/codevalet-webapp:latest'
|
image: 'codevalet/webapp:latest'
|
||||||
ports:
|
ports:
|
||||||
- 9292:9292
|
- 9292:9292
|
||||||
|
links:
|
||||||
|
- cache
|
||||||
|
environment:
|
||||||
|
- USE_MEMCACHED=true
|
||||||
|
- SESSION_SECRET=fiddlesticks
|
||||||
|
- WARDEN_GITHUB_VERIFIER_SECRET=fiddlesticks
|
||||||
|
|
||||||
|
cache:
|
||||||
|
image: 'memcached:alpine'
|
||||||
|
command: '-v'
|
||||||
|
ports:
|
||||||
|
- 11211:11211
|
||||||
|
|
|
@ -15,6 +15,7 @@ items:
|
||||||
selector:
|
selector:
|
||||||
app: 'webapp'
|
app: 'webapp'
|
||||||
|
|
||||||
|
|
||||||
- apiVersion: extensions/v1beta1
|
- apiVersion: extensions/v1beta1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
|
@ -23,7 +24,7 @@ items:
|
||||||
labels:
|
labels:
|
||||||
name: 'webapp'
|
name: 'webapp'
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 3
|
||||||
strategy:
|
strategy:
|
||||||
type: RollingUpdate
|
type: RollingUpdate
|
||||||
selector:
|
selector:
|
||||||
|
@ -54,16 +55,23 @@ items:
|
||||||
value: 'https://codevalet.io/github/authenticate'
|
value: 'https://codevalet.io/github/authenticate'
|
||||||
- name: GITHUB_CLIENT_ID
|
- name: GITHUB_CLIENT_ID
|
||||||
value: '790a28783a813e2b2b3c'
|
value: '790a28783a813e2b2b3c'
|
||||||
|
- name: MEMCACHED_SERVER
|
||||||
|
value: 'memcached.webapp.svc.cluster.local'
|
||||||
|
- name: SESSION_SECRET
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: 'webapp'
|
||||||
|
key: 'sessionsecret'
|
||||||
- name: SENTRY_DSN
|
- name: SENTRY_DSN
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: webapp
|
name: 'webapp'
|
||||||
key: sentry
|
key: 'sentry'
|
||||||
- name: GITHUB_CLIENT_SECRET
|
- name: GITHUB_CLIENT_SECRET
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: oauth
|
name: 'oauth'
|
||||||
key: secret
|
key: 'secret'
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /
|
path: /
|
||||||
|
@ -71,6 +79,60 @@ items:
|
||||||
initialDelaySeconds: 60
|
initialDelaySeconds: 60
|
||||||
timeoutSeconds: 10
|
timeoutSeconds: 10
|
||||||
|
|
||||||
|
- apiVersion: extensions/v1beta1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: 'memcached'
|
||||||
|
namespace: 'webapp'
|
||||||
|
labels:
|
||||||
|
name: 'memcached'
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
strategy:
|
||||||
|
type: RollingUpdate
|
||||||
|
selector:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: 'memcached'
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: 'cache'
|
||||||
|
image: 'memcached:alpine'
|
||||||
|
imagePullPolicy: Always
|
||||||
|
ports:
|
||||||
|
- containerPort: 11211
|
||||||
|
name: 'memcached'
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: 64M
|
||||||
|
limits:
|
||||||
|
memory: 256M
|
||||||
|
livenessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: 'memcached'
|
||||||
|
initialDelaySeconds: 30
|
||||||
|
timeoutSeconds: 5
|
||||||
|
readinessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: 'memcached'
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
timeoutSeconds: 1
|
||||||
|
|
||||||
|
- apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: 'memcached'
|
||||||
|
namespace: 'webapp'
|
||||||
|
spec:
|
||||||
|
clusterIP: None
|
||||||
|
ports:
|
||||||
|
- port: 11211
|
||||||
|
targetPort: 'memcached'
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
app: 'memcached'
|
||||||
|
|
||||||
- apiVersion: extensions/v1beta1
|
- apiVersion: extensions/v1beta1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
|
|
|
@ -87,7 +87,7 @@ items:
|
||||||
runAsUser: 0
|
runAsUser: 0
|
||||||
containers:
|
containers:
|
||||||
- name: "jenkins-@@USER@@"
|
- name: "jenkins-@@USER@@"
|
||||||
image: "rtyler/codevalet-master:latest"
|
image: "codevalet/master:latest"
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
|
|
|
@ -1,12 +1,28 @@
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
# Web framework, yey
|
||||||
gem 'sinatra'
|
gem 'sinatra'
|
||||||
gem 'haml'
|
|
||||||
gem 'warden-github'
|
# The actual webserver
|
||||||
gem 'kramdown'
|
|
||||||
gem 'sentry-raven'
|
|
||||||
gem 'puma'
|
gem 'puma'
|
||||||
|
|
||||||
|
# For rendering all the views
|
||||||
|
gem 'haml'
|
||||||
|
|
||||||
|
# Provides some semblance of github-based authentication and authorization
|
||||||
|
# within the rack app
|
||||||
|
gem 'warden-github'
|
||||||
|
|
||||||
|
# Responsible for markdown parsing in the webapp views
|
||||||
|
gem 'kramdown'
|
||||||
|
|
||||||
|
# Send exceptions into Sentry from the app
|
||||||
|
gem 'sentry-raven'
|
||||||
|
|
||||||
|
# For memcached access
|
||||||
|
gem 'dalli'
|
||||||
|
gem 'rack-cache'
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ GEM
|
||||||
addressable (2.5.1)
|
addressable (2.5.1)
|
||||||
public_suffix (~> 2.0, >= 2.0.2)
|
public_suffix (~> 2.0, >= 2.0.2)
|
||||||
concurrent-ruby (1.0.5)
|
concurrent-ruby (1.0.5)
|
||||||
|
dalli (2.7.6)
|
||||||
diff-lcs (1.3)
|
diff-lcs (1.3)
|
||||||
faraday (0.12.2)
|
faraday (0.12.2)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
|
@ -25,6 +26,8 @@ GEM
|
||||||
public_suffix (2.0.5)
|
public_suffix (2.0.5)
|
||||||
puma (3.10.0)
|
puma (3.10.0)
|
||||||
rack (2.0.3)
|
rack (2.0.3)
|
||||||
|
rack-cache (1.7.1)
|
||||||
|
rack (>= 0.4)
|
||||||
rack-protection (2.0.0)
|
rack-protection (2.0.0)
|
||||||
rack
|
rack
|
||||||
rspec (3.6.0)
|
rspec (3.6.0)
|
||||||
|
@ -66,13 +69,15 @@ PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
dalli
|
||||||
haml
|
haml
|
||||||
kramdown
|
kramdown
|
||||||
puma
|
puma
|
||||||
|
rack-cache
|
||||||
rspec
|
rspec
|
||||||
sentry-raven
|
sentry-raven
|
||||||
sinatra
|
sinatra
|
||||||
warden-github
|
warden-github
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.15.3
|
1.16.0
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'securerandom'
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
|
require 'dalli'
|
||||||
require 'haml'
|
require 'haml'
|
||||||
|
require 'rack/session/dalli'
|
||||||
require 'sinatra/base'
|
require 'sinatra/base'
|
||||||
require 'warden/github'
|
require 'warden/github'
|
||||||
require 'yaml'
|
|
||||||
|
|
||||||
Haml::TempleEngine.disable_option_validator!
|
Haml::TempleEngine.disable_option_validator!
|
||||||
|
|
||||||
|
@ -24,11 +28,24 @@ module CodeValet
|
||||||
include Warden::GitHub::SSO
|
include Warden::GitHub::SSO
|
||||||
|
|
||||||
enable :sessions
|
enable :sessions
|
||||||
|
set :session_secret, ENV.fetch('SESSION_SECRET') { SecureRandom.hex(64) }
|
||||||
|
|
||||||
enable :raise_errors
|
enable :raise_errors
|
||||||
disable :show_exceptions
|
|
||||||
|
if ENV['PRODUCTION']
|
||||||
|
disable :show_exceptions
|
||||||
|
end
|
||||||
|
|
||||||
set :public_folder, File.dirname(__FILE__) + '/assets'
|
set :public_folder, File.dirname(__FILE__) + '/assets'
|
||||||
|
|
||||||
|
configure do
|
||||||
|
if ENV['PRODUCTION'] || ENV['USE_MEMCACHED']
|
||||||
|
use Rack::Session::Dalli,
|
||||||
|
:namespace => 'webapp.sessions',
|
||||||
|
:cache => Dalli::Client.new(ENV.fetch('MEMCACHED_SERVER') { 'cache:11211' })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
use Warden::Manager do |config|
|
use Warden::Manager do |config|
|
||||||
config.failure_app = AuthFailre
|
config.failure_app = AuthFailre
|
||||||
config.default_strategies :github
|
config.default_strategies :github
|
||||||
|
|
|
@ -3,86 +3,95 @@
|
||||||
{
|
{
|
||||||
:name => 'Ubuntu 16.04',
|
:name => 'Ubuntu 16.04',
|
||||||
:labels => ['ubuntu', 'linux', 'docker'],
|
:labels => ['ubuntu', 'linux', 'docker'],
|
||||||
:capabilities => '',
|
:capabilities => ['Docker-enabled'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:name => 'FreeBSD 11.1',
|
:name => 'FreeBSD 11.1',
|
||||||
:labels => ['freebsd', 'bsd'],
|
:labels => ['freebsd', 'bsd'],
|
||||||
:capabilities => '',
|
:capabilities => [],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
.container
|
.container
|
||||||
.col-md-10
|
.col-md-10
|
||||||
.row
|
.row
|
||||||
%h2
|
|
||||||
Overview
|
|
||||||
.container
|
.container
|
||||||
.row
|
.row
|
||||||
%p
|
.col-lg-12
|
||||||
Code Valet is powered by
|
%h2
|
||||||
%a{:href => 'https://jenkins.io'}
|
Overview
|
||||||
Jenkins® 2
|
%p
|
||||||
with
|
Code Valet is powered by
|
||||||
%a{:href => 'https://jenkins.io/doc/book/pipeline'}
|
%a{:href => 'https://jenkins.io'}
|
||||||
Jenkins Pipeline.
|
Jenkins® 2
|
||||||
|
with
|
||||||
|
%a{:href => 'https://jenkins.io/doc/book/pipeline'}
|
||||||
|
Jenkins Pipeline.
|
||||||
.row
|
.row
|
||||||
%h3
|
.col-lg-12
|
||||||
Features enabled
|
%h3
|
||||||
:markdown
|
Features enabled
|
||||||
The current list of features enabled on Code Valet, which can be
|
%p
|
||||||
used in a `Jenkinsfile` are:
|
:markdown
|
||||||
|
The current list of features enabled on Code Valet, which can be
|
||||||
|
used in a `Jenkinsfile` are:
|
||||||
|
|
||||||
* XML (JUnit) test reporting integration via the `junit` step.
|
* XML (JUnit) test reporting integration via the `junit` step.
|
||||||
* Embedded status badges, such as: [![Build Status](https://codevalet.io/u/codevalet/job/CodeValet/job/codevalet/job/master/badge/icon)](https://codevalet.io/u/codevalet/blue/organizations/jenkins/CodeValet%2Fcodevalet/activity)
|
* Embedded status badges, such as: [![Build Status](https://codevalet.codevalet.io/job/codevalet/job/master/badge/icon)](https://codevalet.codevalet.io/job/codevalet/job/master/)
|
||||||
|
|
||||||
|
|
||||||
.row
|
.row
|
||||||
%h2
|
.col-lg-12
|
||||||
Platforms
|
%h2
|
||||||
|
Platforms
|
||||||
|
|
||||||
.container
|
%p
|
||||||
.row
|
Code Valet provides ephemeral execution environments, dedicated to
|
||||||
%p
|
each user or organization. This provides the best trade-off between
|
||||||
Code Valet provides ephemeral execution environments, dedicated to
|
performance and reliability using the tools currently available.
|
||||||
each user or organization. This provides the best trade-off between
|
%p
|
||||||
performance and reliability using the tools currently available.
|
%table.table
|
||||||
%p
|
%thead
|
||||||
%table.table
|
%tr
|
||||||
%thead
|
%th
|
||||||
|
Platform
|
||||||
|
%th
|
||||||
|
Capabilities
|
||||||
|
%th
|
||||||
|
Example
|
||||||
|
%code
|
||||||
|
Jenkinsfile
|
||||||
|
%tbody
|
||||||
|
- platforms.each do |p|
|
||||||
%tr
|
%tr
|
||||||
%th
|
%td
|
||||||
Platform
|
%p
|
||||||
%th
|
|
||||||
Capabilities
|
|
||||||
%th
|
|
||||||
Example
|
|
||||||
%tbody
|
|
||||||
- platforms.each do |p|
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong= p[:name]
|
%strong= p[:name]
|
||||||
|
%p
|
||||||
|
Labels:
|
||||||
%ul
|
%ul
|
||||||
- p[:labels].each do |label|
|
- p[:labels].each do |label|
|
||||||
%li
|
%li
|
||||||
%code= label
|
%code= label
|
||||||
|
|
||||||
%td
|
%td
|
||||||
= p[:capabilities]
|
- p[:capabilities].each do |cap|
|
||||||
%td
|
%p
|
||||||
%pre
|
= cap
|
||||||
%code
|
%td
|
||||||
:plain
|
%pre
|
||||||
pipeline {
|
%code
|
||||||
agent { label '#{p[:labels].first}' }
|
:plain
|
||||||
stages {
|
pipeline {
|
||||||
stage('Build') {
|
agent { label '#{p[:labels].first}' }
|
||||||
steps {
|
stages {
|
||||||
sh 'uname -a'
|
stage('Build') {
|
||||||
sh 'cat /etc/issue'
|
steps {
|
||||||
}
|
sh 'uname -a'
|
||||||
|
sh 'cat /etc/issue'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,11 @@
|
||||||
%a.dropdown-item{:href => "https://#{monkey}.codevalet.io/blue"}
|
%a.dropdown-item{:href => "https://#{monkey}.codevalet.io/blue"}
|
||||||
= monkey
|
= monkey
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-lg-12.text-center
|
||||||
%img.img-fluid{:src => '/images/create-new-pipeline.png'}
|
%iframe{:width => 800, :height => 400, :frameborder => 0, :gesture => :media,
|
||||||
|
:allow => 'encrypted-media', :allowfullscreen => '',
|
||||||
|
:src => 'https://www.youtube-nocookie.com/embed/FhDomw6BaHU'}
|
||||||
|
%img.img-fluid{:src => '/images/create-new-pipeline.png'}
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
|
Loading…
Reference in New Issue