Skip to content

Commit

Permalink
Experimental support for injecting custom arbitrary endpoints into ye…
Browse files Browse the repository at this point in the history
…lb-ui and yelb-appserver
  • Loading branch information
mreferre committed Mar 14, 2018
1 parent 3287e47 commit 740ab92
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 33 deletions.
4 changes: 2 additions & 2 deletions deployments/localdevelopment/setupdevenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# workstation requirements: git, Docker, Ruby (with proper libraries/gems), angular@CLI

docker run --name redis -p 6379:6379 -d redis:4.0.2
docker run --name postgres -p 5432:5432 -d mreferre/yelb-db:0.2
docker run --name postgres -p 5432:5432 -d mreferre/yelb-db:0.3

cd ./yelb/yelb-appserver
export RACK_ENV=development
Expand All @@ -24,7 +24,7 @@ cp ../clarity-seed-newfiles/src/styles.css src/styles.css
cp ../clarity-seed-newfiles/src/app/app* src/app
cp ../clarity-seed-newfiles/src/environments/env* src/environments
cp ../clarity-seed-newfiles/package.json package.json
cp ../clarity-seed-newfiles/angular-cli.json angular-cli.json
cp ../clarity-seed-newfiles/angular-cli.json .angular-cli.json
rm -r src/app/home
rm -r src/app/about

Expand Down
6 changes: 3 additions & 3 deletions deployments/localtest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Move to the directory where you want to work and clone the repo:
```
docker network create yelb-network
docker run --name redis-server -p 6379:6379 --network=yelb-network -d redis:4.0.2
docker run --name yelb-db -p 5432:5432 --network=yelb-network -d mreferre/yelb-db:0.2
docker run --name yelb-appserver --network=yelb-network -d -p 4567:4567 -e RACK_ENV=test mreferre/yelb-appserver:0.2
docker run --name yelb-ui --network=yelb-network -d -p 8080:80 -e UI_ENV=test mreferre/yelb-ui:0.2
docker run --name yelb-db -p 5432:5432 --network=yelb-network -d mreferre/yelb-db:0.3
docker run --name yelb-appserver --network=yelb-network -d -p 4567:4567 -e RACK_ENV=test mreferre/yelb-appserver:0.3
docker run --name yelb-ui --network=yelb-network -d -p 8080:80 -e UI_ENV=test mreferre/yelb-ui:0.3
```
You should now be able to see the application running by connecting your browser to: http://localhost:8080

Expand Down
6 changes: 3 additions & 3 deletions deployments/localtest/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: "2.1"
services:
yelb-ui:
image: mreferre/yelb-ui:0.2
image: mreferre/yelb-ui:0.3
depends_on:
- yelb-appserver
ports:
Expand All @@ -11,7 +11,7 @@ services:
- UI_ENV=test # dev | test | prod

yelb-appserver:
image: mreferre/yelb-appserver:0.2
image: mreferre/yelb-appserver:0.3
depends_on:
- redis-server
- yelb-db
Expand All @@ -26,6 +26,6 @@ services:
- 6379:6379

yelb-db:
image: mreferre/yelb-db:0.2
image: mreferre/yelb-db:0.3
ports:
- 5432:5432
6 changes: 3 additions & 3 deletions deployments/platformdeployment/Docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: "2.1"
services:
yelb-ui:
image: mreferre/yelb-ui:0.2
image: mreferre/yelb-ui:0.3
depends_on:
- yelb-appserver
ports:
Expand All @@ -11,7 +11,7 @@ services:
- yelb-network

yelb-appserver:
image: mreferre/yelb-appserver:0.2
image: mreferre/yelb-appserver:0.3
depends_on:
- redis-server
- yelb-db
Expand All @@ -27,7 +27,7 @@ services:
# - redisdata:/data

yelb-db:
image: mreferre/yelb-db:0.2
image: mreferre/yelb-db:0.3
networks:
- yelb-network
# uncomment the following lines if you want to persist postgres data across deployments
Expand Down
6 changes: 3 additions & 3 deletions deployments/platformdeployment/Docker/stack-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: "3"
services:
yelb-ui:
image: mreferre/yelb-ui:0.2
image: mreferre/yelb-ui:0.3
depends_on:
- yelb-appserver
ports:
Expand All @@ -15,7 +15,7 @@ services:
condition: on-failure

yelb-appserver:
image: mreferre/yelb-appserver:0.2
image: mreferre/yelb-appserver:0.3
depends_on:
- redis-server
- yelb-db
Expand All @@ -39,7 +39,7 @@ services:
condition: on-failure

yelb-db:
image: mreferre/yelb-db:0.2
image: mreferre/yelb-db:0.3
networks:
- yelb-network
# uncomment the following lines if you want to persist postgres data across deployments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:
spec:
containers:
- name: yelb-ui
image: mreferre/yelb-ui:0.2
image: mreferre/yelb-ui:0.3
ports:
- containerPort: 80
---
Expand Down Expand Up @@ -111,7 +111,7 @@ spec:
spec:
containers:
- name: yelb-db
image: mreferre/yelb-db:0.2
image: mreferre/yelb-db:0.3
ports:
- containerPort: 5432
---
Expand All @@ -129,6 +129,8 @@ spec:
spec:
containers:
- name: yelb-appserver
image: mreferre/yelb-appserver:0.2
image: mreferre/yelb-appserver:0.3
ports:
- containerPort: 4567


Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
spec:
containers:
- name: yelb-ui
image: mreferre/yelb-ui:0.2
image: mreferre/yelb-ui:0.3
ports:
- containerPort: 80
hostPort: 32777 # depending on the minikube driver you use you may be able to even use 80. But something above 32000 seems safer
Expand Down Expand Up @@ -98,7 +98,7 @@ spec:
spec:
containers:
- name: yelb-db
image: mreferre/yelb-db:0.2
image: mreferre/yelb-db:0.3
ports:
- containerPort: 5432
---
Expand All @@ -116,7 +116,7 @@ spec:
spec:
containers:
- name: yelb-appserver
image: mreferre/yelb-appserver:0.2
image: mreferre/yelb-appserver:0.3
ports:
- containerPort: 4567

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ spec:
spec:
containers:
- name: yelb-ui
image: mreferre/yelb-ui:0.2
image: mreferre/yelb-ui:0.3
ports:
- containerPort: 80
---
Expand Down Expand Up @@ -123,7 +123,7 @@ spec:
spec:
containers:
- name: yelb-db
image: mreferre/yelb-db:0.2
image: mreferre/yelb-db:0.3
ports:
- containerPort: 5432
---
Expand All @@ -141,7 +141,7 @@ spec:
spec:
containers:
- name: yelb-appserver
image: mreferre/yelb-appserver:0.2
image: mreferre/yelb-appserver:0.3
ports:
- containerPort: 4567

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ spec:
spec:
containers:
- name: yelb-ui
image: mreferre/yelb-ui:0.2
image: mreferre/yelb-ui:0.3
ports:
- containerPort: 80
---
Expand Down Expand Up @@ -112,7 +112,7 @@ spec:
spec:
containers:
- name: yelb-db
image: mreferre/yelb-db:0.2
image: mreferre/yelb-db:0.3
ports:
- containerPort: 5432
---
Expand All @@ -130,7 +130,7 @@ spec:
spec:
containers:
- name: yelb-appserver
image: mreferre/yelb-appserver:0.2
image: mreferre/yelb-appserver:0.3
ports:
- containerPort: 4567

Expand Down
13 changes: 8 additions & 5 deletions yelb-appserver/yelb-appserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# without this option, the angular application will spit a `forbidden` error message
disable :protection

# the system variable RACK_ENV controls which environment you are enabling
# the system variable RACK_ENV controls which environment you are enabling
# if you choose 'custom' with RACK_ENV, all systems variables in the section need to be set before launching the yelb-appserver application
configure :production do
set :redishost, "redis-server"
set :port, 4567
Expand All @@ -37,6 +38,12 @@
set :yelbdbhost => "localhost"
set :yelbdbport => 5432
end
configure :custom do
set :redishost, ENV['REDIS_SERVER_ENDPOINT']
set :port, 4567
set :yelbdbhost => ENV['YELB_DB_SERVER_ENDPOINT']
set :yelbdbport => 5432
end

options "*" do
response.headers["Allow"] = "HEAD,GET,PUT,DELETE,OPTIONS"
Expand Down Expand Up @@ -69,7 +76,6 @@ def restaurantsdbupdate(restaurant)
end

get '/api/pageviews' do

headers 'Access-Control-Allow-Origin' => '*'
headers 'Access-Control-Allow-Headers' => 'Authorization,Accepts,Content-Type,X-CSRF-Token,X-Requested-With'
headers 'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS'
Expand All @@ -82,7 +88,6 @@ def restaurantsdbupdate(restaurant)
end #get /api/pageviews

get '/api/hostname' do

headers 'Access-Control-Allow-Origin' => '*'
headers 'Access-Control-Allow-Headers' => 'Authorization,Accepts,Content-Type,X-CSRF-Token,X-Requested-With'
headers 'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS'
Expand All @@ -92,7 +97,6 @@ def restaurantsdbupdate(restaurant)
end #get /api/hostname

get '/api/getstats' do

headers 'Access-Control-Allow-Origin' => '*'
headers 'Access-Control-Allow-Headers' => 'Authorization,Accepts,Content-Type,X-CSRF-Token,X-Requested-With'
headers 'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS'
Expand Down Expand Up @@ -155,4 +159,3 @@ def restaurantsdbupdate(restaurant)
restaurantsdbupdate("bucadibeppo")
@bucadibeppo = restaurantsdbread("bucadibeppo")
end #get /api/bucadibeppo

2 changes: 1 addition & 1 deletion yelb-ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN cp /clarity-seed-newfiles/src/styles.css /clarity-seed/src/styles.css
RUN cp /clarity-seed-newfiles/src/app/app* /clarity-seed/src/app
RUN cp /clarity-seed-newfiles/src/environments/env* /clarity-seed/src/environments
RUN cp /clarity-seed-newfiles/package.json /clarity-seed/package.json
RUN cp /clarity-seed-newfiles/angular-cli.json /clarity-seed/angular-cli.json
RUN cp /clarity-seed-newfiles/angular-cli.json /clarity-seed/.angular-cli.json
RUN rm -r /clarity-seed/src/app/home
RUN rm -r /clarity-seed/src/app/about

Expand Down
3 changes: 2 additions & 1 deletion yelb-ui/clarity-seed-newfiles/angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"environments": {
"dev": "environments/environment.ts",
"test": "environments/environment.test.ts",
"prod": "environments/environment.prod.ts"
"prod": "environments/environment.prod.ts",
"custom": "environments/environment.custom.ts"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const environment = {
production: true,
envName: 'custom',
appserver_env: 'http://' + 'YELB_APPSERVER_ENDPOINT'
};

0 comments on commit 740ab92

Please sign in to comment.