roro 0.3.17 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +11 -10
- data/.gitignore +3 -2
- data/Guardfile +8 -10
- data/README.md +2 -1
- data/lib/roro.rb +1 -0
- data/lib/roro/cli.rb +13 -7
- data/lib/roro/cli/generate/story.rb +18 -0
- data/lib/roro/cli/greenfield/rails.rb +2 -24
- data/lib/roro/cli/rollon.rb +135 -8
- data/lib/roro/cli/rollon/rails/base/base.rb +4 -0
- data/lib/roro/cli/{base → rollon/rails/base}/insert_gems.rb +2 -10
- data/lib/roro/cli/{base → rollon/rails/base}/insertions.rb +8 -0
- data/lib/roro/cli/rollon/rails/database.rb +4 -8
- data/lib/roro/cli/rollon/rails/database/with_mysql.rb +2 -2
- data/lib/roro/cli/rollon/rails/database/with_postgresql.rb +3 -4
- data/lib/roro/cli/rollon/ruby_gem/with_ci_cd.rb +7 -7
- data/lib/roro/configurator.rb +15 -0
- data/lib/roro/configurator/eligibility.rb +137 -0
- data/lib/roro/configurator/okonomi.rb +28 -0
- data/lib/roro/configurator/omakase.rb +170 -0
- data/lib/roro/stories/greenfield.yml +1 -0
- data/lib/roro/stories/greenfield/rails.yml +9 -0
- data/lib/roro/stories/rollon.yml +42 -0
- data/lib/roro/stories/rollon/rails.yml +76 -0
- data/lib/roro/stories/rollon/rails/ci_cd.yml +1 -0
- data/lib/roro/stories/rollon/rails/ci_cd/circleci.yml +2 -0
- data/lib/roro/stories/rollon/rails/database.yml +9 -0
- data/lib/roro/stories/rollon/rails/database/mysql.yml +17 -0
- data/lib/roro/stories/rollon/rails/database/postgresql.yml +15 -0
- data/lib/roro/stories/rollon/rails/kubernetes.yml +1 -0
- data/lib/roro/stories/rollon/rails/kubernetes/postgresql.yml +10 -0
- data/lib/roro/stories/rollon/rails/kubernetes/postgresql/default.yml +1 -0
- data/lib/roro/stories/rollon/rails/kubernetes/postgresql/edge.yml +1 -0
- data/lib/roro/stories/rollon/ruby_gem.yml +5 -0
- data/lib/roro/{cli/templates/rails → templates/base}/.circleci/_aliases.yml +0 -0
- data/lib/roro/templates/base/.circleci/_commands.yml +31 -0
- data/lib/roro/templates/base/.circleci/_defaults.yml +5 -0
- data/lib/roro/templates/base/.circleci/_executors.yml +11 -0
- data/lib/roro/templates/base/.circleci/_major_only.yml +4 -0
- data/lib/roro/templates/base/.circleci/_version.yml +1 -0
- data/lib/roro/{cli/templates → templates}/base/.circleci/_workflow.yml +0 -0
- data/lib/roro/{cli/templates → templates}/base/.circleci/config.job-example.yml +5 -5
- data/lib/roro/{cli/templates → templates}/base/.circleci/jobs/_build.yml +0 -0
- data/lib/roro/{cli/templates → templates}/base/.circleci/jobs/_release.yml +0 -0
- data/lib/roro/{cli/templates → templates}/base/.circleci/workflows/_build_release.yml +0 -0
- data/lib/roro/{cli/templates → templates}/base/.dockerignore +0 -0
- data/lib/roro/{cli/templates → templates}/base/dotenv +0 -0
- data/lib/roro/{cli/templates → templates}/base/jumpstart/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/base/jumpstart/Dockerfile.tt +0 -0
- data/lib/roro/{cli/templates → templates}/base/jumpstart/docker-compose.yml +0 -0
- data/lib/roro/{cli/templates → templates}/base/jumpstart/docker-entrypoint.sh +0 -0
- data/lib/roro/{cli/templates → templates}/base/livereload/hosts.example +0 -0
- data/lib/roro/{cli/templates → templates}/base/roro/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/base/roro/roro/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/base/roro/roro/containers/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/base/roro/roro/containers/app/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/base/roro/roro/containers/frontend/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/base/roro/roro/docker-entrypoint.sh.tt +0 -0
- data/lib/roro/{cli/templates → templates}/rails/.circleci/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/rails/.circleci/config.yml.tt +4 -6
- data/lib/roro/{cli/templates → templates}/rails/.circleci/jobs/_build.yml +4 -6
- data/lib/roro/templates/rails/.circleci/jobs/_push.yml +11 -0
- data/lib/roro/templates/rails/.circleci/jobs/_test.yml +12 -0
- data/lib/roro/{cli/templates → templates}/rails/.circleci/setup-gem-credentials.sh +0 -0
- data/lib/roro/templates/rails/.circleci/workflows/_build_test_push.yml +12 -0
- data/lib/roro/{cli/templates → templates}/rails/.keep +0 -0
- data/lib/roro/templates/rails/Dockerfile.greenfield.tt +51 -0
- data/lib/roro/{cli/templates → templates}/rails/config/database.mysql.yml +0 -0
- data/lib/roro/{cli/templates → templates}/rails/config/database.pg.yml +2 -3
- data/lib/roro/{cli/templates/stories → templates/rails/database}/with_mysql/_service.yml +0 -0
- data/lib/roro/{cli/templates → templates}/rails/database/with_postgresql/.keep +0 -0
- data/lib/roro/{cli/templates/stories → templates/rails/database}/with_postgresql/_service.yml +0 -0
- data/lib/roro/{cli/templates → templates}/rails/docker-compose.yml.tt +3 -3
- data/lib/roro/{cli/templates → templates}/rails/dotenv/.keep +0 -0
- data/lib/roro/templates/rails/dotenv/database.mysql.env.tt +6 -0
- data/lib/roro/templates/rails/dotenv/database.pg.env.tt +4 -0
- data/lib/roro/{cli/templates → templates}/rails/dotenv/web.env.tt +0 -0
- data/lib/roro/templates/rails/kube.rake.tt +114 -0
- data/lib/roro/{cli/templates → templates}/rails/roro/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/rails/roro/containers/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/rails/roro/containers/app/.keep +0 -0
- data/lib/roro/templates/rails/roro/containers/app/Dockerfile.tt +34 -0
- data/lib/roro/{cli/templates → templates}/rails/roro/containers/frontend/.keep +0 -0
- data/lib/roro/{cli/templates/rails/roro/docker-entrypoint.sh.tt → templates/rails/roro/docker-entrypoint.sh} +0 -0
- data/lib/roro/{cli/templates/rails/roro/roro → templates/rails/roro/kube}/.keep +0 -0
- data/lib/roro/{cli/templates/rails/roro/roro/containers/.keep → templates/rails/roro/kube/certificate.yml.tt} +0 -0
- data/lib/roro/{cli/templates/rails/roro/roro/containers/app/.keep → templates/rails/roro/kube/cluster-issuer.yml.tt} +0 -0
- data/lib/roro/templates/rails/roro/kube/deployment.yml.tt +50 -0
- data/lib/roro/templates/rails/roro/kube/deployments/postgres_deploy.yaml +47 -0
- data/lib/roro/templates/rails/roro/kube/deployments/rails_deploy.yaml +62 -0
- data/lib/roro/templates/rails/roro/kube/deployments/redis_deploy.yaml +23 -0
- data/lib/roro/templates/rails/roro/kube/deployments/sidekiq_deploy.yaml +56 -0
- data/lib/roro/{cli/templates/rails/roro/roro/containers/frontend/.keep → templates/rails/roro/kube/ingress.yml.tt} +0 -0
- data/lib/roro/templates/rails/roro/kube/ingresses/ingress.yaml +13 -0
- data/lib/roro/{cli/templates/ruby_gem/.circleci/.keep → templates/rails/roro/kube/job-migrate.yml.tt} +0 -0
- data/lib/roro/templates/rails/roro/kube/jobs/setup.yaml +42 -0
- data/lib/roro/templates/rails/roro/kube/secret-digital-ocean.yml.tt +4 -0
- data/lib/roro/templates/rails/roro/kube/service.yml.tt +10 -0
- data/lib/roro/templates/rails/roro/kube/services/postgres_svc.yaml +13 -0
- data/lib/roro/templates/rails/roro/kube/services/rails_svc.yaml +13 -0
- data/lib/roro/templates/rails/roro/kube/services/redis_svc.yaml +13 -0
- data/lib/roro/templates/rails/roro/kube/volumes/postgres_volumes.yaml +25 -0
- data/lib/roro/{cli/templates/ruby_gem/roro/containers → templates/ruby_gem/.circleci}/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/ruby_gem/.circleci/config.yml.tt +4 -4
- data/lib/roro/templates/ruby_gem/.circleci/jobs/_test.yml +4 -0
- data/lib/roro/{cli/templates → templates}/ruby_gem/.circleci/setup-gem-credentials.sh +0 -0
- data/lib/roro/{cli/templates → templates}/ruby_gem/docker-compose.yml +0 -0
- data/lib/roro/{cli/templates/ruby_gem/roro/keys → templates/ruby_gem/roro/containers}/.keep +0 -0
- data/lib/roro/{cli/templates → templates}/ruby_gem/roro/containers/ruby_image/Dockerfile.tt +1 -1
- data/lib/roro/templates/ruby_gem/roro/containers/ruby_image/ci.env.tt +1 -0
- data/lib/roro/{cli/templates/stories → templates/ruby_gem/roro/keys}/.keep +0 -0
- data/lib/roro/version.rb +1 -1
- metadata +101 -80
- data/lib/roro/cli/base/base.rb +0 -8
- data/lib/roro/cli/base/base_files.rb +0 -24
- data/lib/roro/cli/base/check_dependencies.rb +0 -97
- data/lib/roro/cli/base/continuous_integration.rb +0 -13
- data/lib/roro/cli/base/utilities.rb +0 -38
- data/lib/roro/cli/configuration.rb +0 -69
- data/lib/roro/cli/generate/config.rb +0 -11
- data/lib/roro/cli/generate/config/rails.rb +0 -17
- data/lib/roro/cli/rollon/rails.rb +0 -47
- data/lib/roro/cli/rollon/stories/stories.rb +0 -3
- data/lib/roro/cli/roro_configurator.yml +0 -157
- data/lib/roro/cli/templates/base/.circleci/_defaults.yml +0 -17
- data/lib/roro/cli/templates/base/.roro_config.yml +0 -15
- data/lib/roro/cli/templates/rails/.circleci/jobs/_push.yml +0 -23
- data/lib/roro/cli/templates/rails/.circleci/jobs/_test.yml +0 -13
- data/lib/roro/cli/templates/rails/.circleci/workflows/_build_test_push.yml +0 -9
- data/lib/roro/cli/templates/rails/Dockerfile.greenfield.tt +0 -47
- data/lib/roro/cli/templates/rails/database/with_mysql/_service.yml +0 -10
- data/lib/roro/cli/templates/rails/database/with_postgresql/_service.yml +0 -7
- data/lib/roro/cli/templates/rails/dotenv/database.mysql.env.tt +0 -3
- data/lib/roro/cli/templates/rails/dotenv/database.pg.env.tt +0 -4
- data/lib/roro/cli/templates/rails/roro/containers/app/Dockerfile.tt +0 -88
- data/lib/roro/cli/templates/rails/roro/roro/docker-entrypoint.sh.tt +0 -8
- data/lib/roro/cli/templates/ruby_gem/roro/containers/ruby_image/ci.env.tt +0 -1
- data/lib/roro/cli/templates/stories/ruby_gem/with_ci_cd/_build.yml +0 -11
- data/lib/roro/cli/templates/stories/with_postgresql/.keep +0 -0
- data/lib/tasks/deploy.rake +0 -126
@@ -0,0 +1 @@
|
|
1
|
+
stories: circleci
|
@@ -0,0 +1,17 @@
|
|
1
|
+
env_vars:
|
2
|
+
mysql_root_password: 'root-mysql-password'
|
3
|
+
mysql_password: your-mysql-password
|
4
|
+
mysql_username: 'root'
|
5
|
+
mysql_database_port: '3306'
|
6
|
+
database_vendor: mysql
|
7
|
+
|
8
|
+
actions:
|
9
|
+
- copy_file 'rails/config/database.mysql.yml', 'config/database.yml', @config.env
|
10
|
+
- |
|
11
|
+
Roro::CLI.roro_environments.each do |e|
|
12
|
+
@config.env[:rails_env] = e
|
13
|
+
source = 'rails/dotenv/database.mysql.env.tt'
|
14
|
+
target = "roro/containers/database/#{e}.env"
|
15
|
+
template( source, target, @config.env)
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
env_vars:
|
2
|
+
postgres_username: postgres
|
3
|
+
postgres_password: your-postgres-password
|
4
|
+
database_vendor: postgresql
|
5
|
+
|
6
|
+
actions:
|
7
|
+
- copy_file 'rails/config/database.pg.yml', 'config/database.yml', @config.env
|
8
|
+
- |
|
9
|
+
Roro::CLI.roro_environments.each do |e|
|
10
|
+
@config.env[:rails_env] = e
|
11
|
+
source = 'rails/dotenv/database.pg.env.tt'
|
12
|
+
target = "roro/containers/database/#{e}.env"
|
13
|
+
template( source, target, @config.env)
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
stories: postgresql
|
@@ -0,0 +1,10 @@
|
|
1
|
+
stories:
|
2
|
+
- default
|
3
|
+
- edge
|
4
|
+
|
5
|
+
actions:
|
6
|
+
- template 'rails/.circleci/config.yml.tt', './.circleci/config.yml'
|
7
|
+
- template 'rails/docker-compose.yml.tt', './docker-compose.yml', @config.env
|
8
|
+
- template 'base/dotenv', './.env', @config.env
|
9
|
+
- directory 'rails/roro', './roro', @config.env
|
10
|
+
- template 'rails/kube.rake.tt', './lib/tasks/kube.rake', @config.env
|
@@ -0,0 +1 @@
|
|
1
|
+
actions:
|
@@ -0,0 +1 @@
|
|
1
|
+
actions:
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
commands:
|
2
|
+
setup-docker-builds:
|
3
|
+
steps:
|
4
|
+
- setup_remote_docker:
|
5
|
+
docker_layer_caching: false
|
6
|
+
|
7
|
+
source-ci-vars:
|
8
|
+
steps:
|
9
|
+
- run: |
|
10
|
+
echo 'source roro/containers/app/ci.env' >> ${BASH_ENV}
|
11
|
+
source ${BASH_ENV}
|
12
|
+
|
13
|
+
attach-roro:
|
14
|
+
steps:
|
15
|
+
- attach_workspace:
|
16
|
+
at: workspace
|
17
|
+
- run: cp -rf workspace/roro .
|
18
|
+
- source-ci-vars
|
19
|
+
|
20
|
+
tag-and-push:
|
21
|
+
parameters:
|
22
|
+
deploy_tag:
|
23
|
+
type: string
|
24
|
+
default: latest
|
25
|
+
steps:
|
26
|
+
- run: |
|
27
|
+
SOURCE=$(docker images | grep project_app | awk '{ print $3 }')
|
28
|
+
DOCKER_REPO=${DOCKER_ORG}/${APP_NAME}_app
|
29
|
+
TAGGED_IMAGE=${DOCKER_REPO}:<< parameters.deploy_tag >>
|
30
|
+
docker tag ${SOURCE} ${TAGGED_IMAGE}
|
31
|
+
docker push ${TAGGED_IMAGE}
|
@@ -0,0 +1 @@
|
|
1
|
+
version: 2.1
|
File without changes
|
@@ -18,16 +18,16 @@ jobs:
|
|
18
18
|
- run: docker-compose build
|
19
19
|
- run: docker-compose up -d
|
20
20
|
- run: docker-compose exec app bin/rails db:create db:migrate
|
21
|
-
- run: docker login -u $
|
21
|
+
- run: docker login -u $docker_USER -p $DOCKER_PASS
|
22
22
|
- run:
|
23
23
|
name: Tag app image
|
24
|
-
command: docker tag $(docker images | grep project_app | awk '{ print $3 }') ${
|
24
|
+
command: docker tag $(docker images | grep project_app | awk '{ print $3 }') ${DOCKER_ORG_NAME}/${APP_NAME}_app:$DEPLOY_TAG
|
25
25
|
- run:
|
26
26
|
name: Tag web image
|
27
|
-
command: docker tag $(docker images | grep project_web | awk '{ print $3 }') ${
|
27
|
+
command: docker tag $(docker images | grep project_web | awk '{ print $3 }') ${DOCKER_ORG_NAME}/${APP_NAME}_web:$DEPLOY_TAG
|
28
28
|
|
29
29
|
|
30
|
-
- run: docker push ${
|
31
|
-
- run: docker push ${
|
30
|
+
- run: docker push ${DOCKER_ORG_NAME}/${APP_NAME}_app:$DEPLOY_TAG
|
31
|
+
- run: docker push ${DOCKER_ORG_NAME}/${APP_NAME}_web:$DEPLOY_TAG
|
32
32
|
|
33
33
|
- run: rake --rakefile .circleci/Rakefile
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,13 +1,11 @@
|
|
1
|
-
<%= yaml_from_template("
|
2
|
-
|
1
|
+
<%= yaml_from_template("base/.circleci/_version.yml") %>
|
3
2
|
<%= yaml_from_template("base/.circleci/_defaults.yml") %>
|
3
|
+
<%= yaml_from_template("base/.circleci/_major_only.yml") %>
|
4
|
+
<%= yaml_from_template("base/.circleci/_executors.yml") %>
|
5
|
+
<%= yaml_from_template("base/.circleci/_commands.yml") %>
|
4
6
|
|
5
7
|
<%= yaml_from_template("rails/.circleci/jobs/_build.yml") %>
|
6
|
-
|
7
8
|
<%= yaml_from_template("rails/.circleci/jobs/_test.yml") %>
|
8
|
-
|
9
9
|
<%= yaml_from_template("rails/.circleci/jobs/_push.yml") %>
|
10
|
-
|
11
10
|
<%= yaml_from_template("base/.circleci/_workflow.yml") %>
|
12
|
-
|
13
11
|
<%= yaml_from_template("rails/.circleci/workflows/_build_test_push.yml") %>
|
@@ -1,16 +1,14 @@
|
|
1
|
+
jobs:
|
1
2
|
build:
|
2
3
|
<<: *defaults
|
3
4
|
steps:
|
4
5
|
- checkout
|
5
|
-
- run:
|
6
|
-
|
7
|
-
roro generate::exposed ci
|
6
|
+
- run: gem install roro
|
7
|
+
- run: roro generate::exposed ci
|
8
8
|
- run: |
|
9
9
|
mkdir -p workspace
|
10
10
|
cp -r roro workspace/
|
11
11
|
- persist_to_workspace:
|
12
12
|
root: workspace
|
13
13
|
paths:
|
14
|
-
- roro
|
15
|
-
- run: *source-ci-variables
|
16
|
-
- run: RORO_ENV=ci docker-compose build
|
14
|
+
- roro
|
@@ -0,0 +1,12 @@
|
|
1
|
+
test:
|
2
|
+
<<: *defaults
|
3
|
+
steps:
|
4
|
+
- checkout
|
5
|
+
- attach-roro
|
6
|
+
- run: docker-compose build
|
7
|
+
- run: docker-compose up -d
|
8
|
+
- run: docker-compose run app bundle
|
9
|
+
- run: docker-compose run app yarn
|
10
|
+
- run: docker-compose run app bin/rails db:create
|
11
|
+
- run: docker-compose run app bin/rails db:migrate
|
12
|
+
- run: docker-compose run app bin/rails test
|
File without changes
|
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
FROM ruby:<%= config[:ruby_version] %>-alpine AS builder
|
2
|
+
|
3
|
+
LABEL maintainer="<%= config[:docker_email] %> using RoRo"
|
4
|
+
|
5
|
+
# Add basic packages
|
6
|
+
RUN apk add --no-cache \
|
7
|
+
build-base \
|
8
|
+
postgresql-dev \
|
9
|
+
git \
|
10
|
+
nodejs \
|
11
|
+
yarn \
|
12
|
+
tzdata \
|
13
|
+
file
|
14
|
+
|
15
|
+
## Set APP_HOME and BUNDLE_PATH as using ENV instructions:
|
16
|
+
ENV APP_HOME /usr/src/app/
|
17
|
+
ENV BUNDLE_PATH /gems
|
18
|
+
|
19
|
+
## Create both as directories to make sure they exist:
|
20
|
+
RUN mkdir -p ${APP_HOME}
|
21
|
+
RUN mkdir ${BUNDLE_PATH}
|
22
|
+
|
23
|
+
## Tell Docker to create volumes for our workspace and gems
|
24
|
+
## so other containers can access them.
|
25
|
+
|
26
|
+
RUN gem install bundler:2.1.4
|
27
|
+
|
28
|
+
WORKDIR ${APP_HOME}
|
29
|
+
|
30
|
+
## Create a Gemfile with just the Rails gem inside:
|
31
|
+
RUN echo -e "source 'https://rubygems.org'\ngem 'rails'" > Gemfile
|
32
|
+
|
33
|
+
## Bundle to install rails:
|
34
|
+
RUN bundle install
|
35
|
+
|
36
|
+
## Use Rails to generate a new app. We'll configure it later.
|
37
|
+
RUN bundle exec rails new . \
|
38
|
+
--database=postgresql \
|
39
|
+
--skip-bundle \
|
40
|
+
--skip-webpack-install
|
41
|
+
RUN bundle --jobs 4
|
42
|
+
RUN bundle exec rails webpacker:install
|
43
|
+
RUN bundle exec rails yarn:install
|
44
|
+
## Tell docker not to create a layer:
|
45
|
+
FROM scratch AS export-stage
|
46
|
+
|
47
|
+
## Copy the generated files onto the host. Note that because we are in a
|
48
|
+
## new container, we don't have access to the previous ${APP_HOME}
|
49
|
+
## variable and so we must hard code it as our source:
|
50
|
+
COPY --from=builder /usr/src/app/ .
|
51
|
+
|
File without changes
|
@@ -2,9 +2,9 @@ default: &default
|
|
2
2
|
adapter: postgresql
|
3
3
|
encoding: unicode
|
4
4
|
host: <%= ENV.fetch('DATABASE_HOST') %>
|
5
|
-
username: <%= ENV.fetch('
|
5
|
+
username: <%= ENV.fetch('POSTGRES_USERNAME') %>
|
6
6
|
password: <%= ENV.fetch('POSTGRES_PASSWORD') %>
|
7
|
-
database: <%= ENV.fetch('
|
7
|
+
database: <%= ENV.fetch('POSTGRES_DATABASE') %>
|
8
8
|
pool: 5
|
9
9
|
variables:
|
10
10
|
statement_timeout: 5000
|
@@ -15,6 +15,5 @@ development:
|
|
15
15
|
test:
|
16
16
|
<<: *default
|
17
17
|
|
18
|
-
|
19
18
|
production:
|
20
19
|
<<: *default
|
File without changes
|
File without changes
|
data/lib/roro/{cli/templates/stories → templates/rails/database}/with_postgresql/_service.yml
RENAMED
File without changes
|
@@ -2,7 +2,7 @@ version: '3.2'
|
|
2
2
|
|
3
3
|
services:
|
4
4
|
|
5
|
-
|
5
|
+
app:
|
6
6
|
build:
|
7
7
|
context: .
|
8
8
|
dockerfile: roro/containers/app/Dockerfile
|
@@ -10,7 +10,6 @@ services:
|
|
10
10
|
- database
|
11
11
|
- redis
|
12
12
|
|
13
|
-
command: ["bin/rails", "s", "-b", "0.0.0.0"]
|
14
13
|
ports:
|
15
14
|
- "3000:3000"
|
16
15
|
- "4000:4000"
|
@@ -22,6 +21,7 @@ services:
|
|
22
21
|
- roro/containers/database/${RORO_ENV:-development}.env
|
23
22
|
environment:
|
24
23
|
- WEBPACKER_DEV_SERVER_HOST=webpack_dev_server
|
24
|
+
command: ["bin/rails", "s", "-b", "0.0.0.0"]
|
25
25
|
|
26
26
|
webpack_dev_server:
|
27
27
|
build:
|
@@ -44,7 +44,7 @@ services:
|
|
44
44
|
redis:
|
45
45
|
image: redis
|
46
46
|
|
47
|
-
<%= yaml_from_template("rails/database/with_#{config[
|
47
|
+
<%= yaml_from_template("rails/database/with_#{config[:database_vendor]}/_service.yml") %>
|
48
48
|
|
49
49
|
system_tests:
|
50
50
|
image: selenium/standalone-chrome-debug
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
MYSQL_DATABASE=<%= config[:main_app_name] + "_" + config[:rails_env] + "_db" %>
|
2
|
+
MYSQL_DATABASE_PORT=<%= config[:mysql_database_port] %>
|
3
|
+
MYSQL_ROOT_PASSWORD=<%= config[:mysql_root_password] %>
|
4
|
+
MYSQL_PASSWORD=<%= config[:mysql_password] %>
|
5
|
+
MYSQL_USERNAME=<%= config[:mysql_username] %>
|
6
|
+
RAILS_ENV=<%= config[:rails_env] %>
|
File without changes
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# require 'dotenv/tasks'
|
2
|
+
|
3
|
+
# Rake.application.options.trace = false
|
4
|
+
|
5
|
+
# Dotenv.load('.env.production.cluster')
|
6
|
+
|
7
|
+
namespace :kube do
|
8
|
+
|
9
|
+
desc 'Rollout a new deployment'
|
10
|
+
task :deploy do
|
11
|
+
apply "kube/deployment.yml"
|
12
|
+
puts `kubectl rollout restart deployment <%= config[:main_app_name] %>-deployment`
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Print useful information aout our Kubernete setup'
|
16
|
+
task :list do
|
17
|
+
kubectl 'get pods --all-namespaces'
|
18
|
+
kubectl 'get services --all-namespaces'
|
19
|
+
kubectl 'get ingresses --all-namespaces'
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Apply our Kubernete configurations to our cluster'
|
23
|
+
task :setup do
|
24
|
+
|
25
|
+
kubectl "apply -f #{Rails.root}/roro/kube/service.yml"
|
26
|
+
|
27
|
+
# # Add our Docker Hub credentials to our cluster
|
28
|
+
# kubectl(%Q{create secret docker-registry regcred \
|
29
|
+
# --docker-server=#{ENV['DOCKER_REGISTRY_SERVER']} \
|
30
|
+
# --docker-username=#{ENV['DOCKER_USERNAME']} \
|
31
|
+
# --docker-password=#{ENV['DOCKER_PASSWORD']} \
|
32
|
+
# --docker-email=#{ENV['DOCKER_EMAIL']} || true
|
33
|
+
# })
|
34
|
+
|
35
|
+
# # Install our Service Component
|
36
|
+
# apply "kube/service.yml"
|
37
|
+
|
38
|
+
# # Install our Rails app Deployment
|
39
|
+
# apply "kube/deployment.yml"
|
40
|
+
|
41
|
+
# # Installs Nginx Ingress controller
|
42
|
+
# apply "https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml"
|
43
|
+
|
44
|
+
# # Add a load balancer
|
45
|
+
# apply "https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud-generic.yaml"
|
46
|
+
|
47
|
+
# # Install our Ingress that will link our load balancer to our service(s)
|
48
|
+
# apply "kube/ingress.yml"
|
49
|
+
|
50
|
+
# # Add the Digital Ocean token to the cluster
|
51
|
+
# apply "kube/secret-digital-ocean.yml"
|
52
|
+
|
53
|
+
# # Install cert-manager
|
54
|
+
# kubectl 'create namespace cert-manager'
|
55
|
+
# apply "https://github.com/jetstack/cert-manager/releases/download/v0.14.0/cert-manager.yaml"
|
56
|
+
|
57
|
+
# # Add our certificate
|
58
|
+
# apply "kube/certificate.yml"
|
59
|
+
|
60
|
+
# # Add the certificate issuer
|
61
|
+
# apply "kube/cluster-issuer.yml"
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Set the number of instances to run in the cluster"
|
65
|
+
task :scale, [:count] => [:environment] do |t, args|
|
66
|
+
kubectl "scale deployments/myapp-deployment --replicas #{args[:count]}"
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "Run database migrates the database"
|
70
|
+
task :migrate do
|
71
|
+
apply "kube/job-migrate.yml"
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "Open a session to a pod on the cluster"
|
75
|
+
task :shell do
|
76
|
+
exec "kubectl exec -it #{find_first_pod_name} bash"
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Tail the log files on production"
|
80
|
+
task :logs do
|
81
|
+
exec 'kubectl logs -f -l app=myapp --all-containers'
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "Runs a command in production"
|
85
|
+
task :run, [:command] => [:environment] do |t, args|
|
86
|
+
kubectl "exec -it #{find_first_pod_name} echo $(#{args[:command]})"
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Run rails console in production"
|
90
|
+
task :console do
|
91
|
+
system "kubectl exec -it #{find_first_pod_name} bundle exec rails console"
|
92
|
+
end
|
93
|
+
|
94
|
+
desc "Print the environment variables"
|
95
|
+
task :config do
|
96
|
+
system "kubectl exec -it #{find_first_pod_name} printenv | sort"
|
97
|
+
end
|
98
|
+
|
99
|
+
def apply(configuration)
|
100
|
+
if File.file?(configuration)
|
101
|
+
puts %x{envsubst < #{configuration} | kubectl apply -f -}
|
102
|
+
else
|
103
|
+
kubectl "apply -f #{configuration}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def kubectl(command)
|
108
|
+
print %x{ kubectl #{command} }
|
109
|
+
end
|
110
|
+
|
111
|
+
def find_first_pod_name
|
112
|
+
`kubectl get pods|grep myapp-deployment|awk '{print $1}'|head -n 1`.to_s.strip
|
113
|
+
end
|
114
|
+
end
|