handsome_fencer-circle_c_i 0.1.38 → 0.1.39

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e348249059bb17352d462c9a189467302358f769c9fd4f505133e702994b2660
4
- data.tar.gz: 5262518705ca9ed24c322656031fa425da0cd633c819166201e2a70a0b3dc44c
3
+ metadata.gz: df83db91e5bd2dc538032cb8dde3f4b58631133401a6406a893e0e6d1e3d8b0f
4
+ data.tar.gz: 96bde906b6e2654a5df99b22876ed6e09657d6c4c92dce03f2eaf652e2735ecb
5
5
  SHA512:
6
- metadata.gz: f92cd064efeb62efaf42a618429a081aa6171e91b8f91b37c70ee4b67e9cc6e181e97dba94ec3ec8c2af020ec9fe56d55b5e1d6fb1f6708a7821db16f450f9cc
7
- data.tar.gz: 1a890b95b6b8349c85957aab8cc619c0f414b0fb159eaea4399c434dc560da568e6300a601833971404203028b09d50a9bc0848b43a3aceb4bbe2bf97de8dff6
6
+ metadata.gz: e35e3dde3d7e2720546d90e6d69854041bd388557f35f365b6b2264bf434081f1b2981f9d3cd4a16084c9289f0b0a68ed9e1c7ee1440e85219b03d2264d28687
7
+ data.tar.gz: e1f9df99333c30829973700e843d110a57a5d54959708ac426c7f4f2632a0ca20f0cf2a4e083dfe2c47349e1d70fea32cf5b3541a4fe1409e63e1a3c3e404561
data/README.md CHANGED
@@ -43,27 +43,35 @@ docker-compose version 1.21.0, build 5920eb0
43
43
 
44
44
  ## Greenfielding a fully dockerized Rails application:
45
45
 
46
- 1) Execute the install command:
46
+ 1) Create a directory named after your new, greenfield app and change into that directory:
47
+
48
+ ```bash
49
+ $ mkdir -p sooperdooperapp
50
+ $ cd sooperdooperapp
51
+
52
+ ```
53
+
54
+ 2) Execute the dockerize command:
47
55
 
48
56
  ```bash
49
57
  $ handsome_fencer-circle_c_i dockerize
50
58
  ```
51
59
 
52
- 2) Ask Docker to use Rails to generate our dockerized Rails app:
60
+ 3) Ask Docker to use Rails to generate our dockerized Rails app in our current directory:
53
61
 
54
62
  ```bash
55
63
  $ docker-compose run app rails new .
56
64
  ```
57
65
 
58
- If you're on a linux machine, you may need to chown the newly created files:
66
+ 3a) If you're on a linux machine, you may need to chown the newly created files:
59
67
 
60
68
  ```bash
61
69
  $ sudo chown <username><user group> -R .
62
70
  ```
63
71
 
64
- If that doesn't work, Docker's [documentation](https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user) should get you pointed in the right direction.
72
+ 3b) If that doesn't work, Docker's [documentation](https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user) should get you pointed in the right direction.
65
73
 
66
- 3) Ask Docker to build the necessary images for our app and spool up containers using them:
74
+ 4) Ask Docker to build the necessary images for our app and spool up containers using them:
67
75
 
68
76
  ```bash
69
77
  $ docker-compose up --build
@@ -1,47 +1,76 @@
1
+ require 'byebug'
2
+
1
3
  module HandsomeFencer
2
4
  module CircleCI
5
+
3
6
  class CLI < Thor
4
7
 
5
8
  desc "dockerize", "This will generate files necessary to dockerize your project, along with a set of files for continuous deployment using CircleCI"
6
9
 
7
10
  def dockerize
11
+
8
12
  directory "circleci", "./.circleci", recursive: true
9
13
  directory "docker", "docker", recursive: true
10
14
  directory "lib", "lib", recursive: true
11
15
  copy_file "docker-compose.yml", "docker-compose.yml"
12
- copy_file "Gemfile", "Gemfile" unless File.exist? "Gemfile"
13
- copy_file "Gemfile.lock", "Gemfile.lock" unless File.exist? "Gemfile.lock"
16
+ copy_file "Gemfile", "Gemfile"
17
+ copy_file "Gemfile.lock", "Gemfile.lock"
14
18
  copy_file "config/database.yml", "config/database.yml"
15
- copy_file "gitignore", ".gitignore" unless File.exist? ".gitignore"
19
+ copy_file "gitignore", ".gitignore"
16
20
  append_to_file ".gitignore", "\ndocker/**/*.env"
17
21
  append_to_file ".gitignore", "\ndocker/**/*.key"
18
22
 
19
- app_name = ask("Name of your app:")
20
- append_to_file 'docker/env_files/circleci.env', "\nexport APP_NAME=#{app_name}"
21
-
22
- append_to_file 'docker/containers/database/development.env', "\nPOSTGRES_DB=#{app_name}_development"
23
- append_to_file 'docker/containers/database/production.env', "\nPOSTGRES_DB=#{app_name}_production"
24
- {
25
- "SERVER_HOST" => "ip address of your server:",
26
- "DOCKERHUB_EMAIL" => "You'll need an account with Docker hub.docker.com. Please provide your Docker email:",
27
- "DOCKERHUB_USER" => "Please provide your Docker username here:",
28
- "DOCKERHUB_PASS" => "Please provide your Docker password here:"
29
- }.each do |env_var, prompt|
30
- variable_value = ask(prompt)
31
- append_to_file 'docker/env_files/circleci.env', "\nexport #{env_var}=#{variable_value}"
23
+ prompts = {
24
+ "APP_NAME" => "the name of your app",
25
+ "SERVER_HOST" => "the ip address of your server",
26
+ "DOCKERHUB_EMAIL" => "your Docker Hub email",
27
+ "DOCKERHUB_USER" => "your Docker Hub username",
28
+ "POSTGRES_USER" => "your Postgres username",
29
+ "POSTGRES_PASSWORD" => "your Postgres password",
30
+ "DOCKERHUB_PASS" => "your Docker Hub password"
31
+ }
32
+
33
+ prompts.map do |key, prompt|
34
+ prompts[key] = ask("Please provide #{prompt}:")
32
35
  end
33
- account_type = ask("Will you like to push your images to Docker under user account or organization instead?", :limited_to => %w[o, u])
34
- if account_type == "o"
35
- org_name = ask("Organization name:")
36
- append_to_file 'docker/env_files/circleci.env', "\nexport DOCKERHUB_ORG_NAME=#{org_name}"
36
+
37
+ account_type = ask("Will you be pushing images to Docker Hub under your user name or under your organization name instead?", :limited_to => %w[org user])
38
+ if account_type == "org"
39
+ prompts['DOCKERHUB_ORG_NAME']= ask("Organization name:")
37
40
  else
38
- append_to_file 'docker/env_files/circleci.env', "\nexport DOCKERHUB_ORG_NAME=${DOCKERHUB_USER}"
41
+ prompts['DOCKERHUB_ORG_NAME']= "${DOCKERHUB_USER}"
42
+ end
43
+
44
+ prompts.map do |key, value|
45
+ append_to_file 'docker/env_files/circleci.env', "\nexport #{key}=#{value}"
39
46
  end
40
- {
41
- "APP_NAME" => "Name of your app:"
42
- }.each do |env_var, prompt|
43
- app_name = ask(prompt)
44
- template "docker/overrides/docker-compose.production.yml.tt", "docker/overrides/docker-copose.produciton.yml"
47
+
48
+ %w[development circleci staging production].each do |environment|
49
+ base = "docker/containers/"
50
+
51
+ app_env = create_file "#{base}app/#{environment}.env"
52
+ append_to_file app_env, "DATABASE_HOST=database\n"
53
+ append_to_file app_env, "RAILS_ENV=#{environment}\n"
54
+
55
+ database_env = create_file "#{base}database/#{environment}.env"
56
+ append_to_file database_env, "POSTGRES_USER=postgres\n"
57
+ append_to_file database_env, "POSTGRES_DB=#{prompts['APP_NAME']}_#{environment}\n"
58
+ append_to_file database_env, "POSTGRES_PASSWORD=#{prompts['POSTGRES_PASSWORD']}\n"
59
+
60
+ ssl = (environment == "production") ? true : false
61
+ web_env = create_file "#{base}web/#{environment}.env"
62
+ append_to_file web_env, "CA_SSL=postgres#{ssl}\n"
63
+ end
64
+ %w[circleci production].each do |environment|
65
+ template "docker/overrides/#{environment}.yml.tt", "docker/overrides/#{environment}.yml"
66
+ end
67
+
68
+ %w[app web].each do |container|
69
+ options = {
70
+ email: prompts['DOCKERHUB_EMAIL'],
71
+ app_name: prompts['APP_NAME']
72
+ }
73
+ template "docker/containers/#{container}/Dockerfile.tt", "docker/containers/#{container}/Dockerfile", options
45
74
  end
46
75
  end
47
76
  end
@@ -7,7 +7,7 @@ module HandsomeFencer
7
7
 
8
8
  def obfuscate(*args)
9
9
 
10
- default_environments = %w[circleci development production]
10
+ default_environments = %w[circleci development staging production]
11
11
  environments = args.first ? args.first : default_environments
12
12
  environments.each do |environment|
13
13
  @cipher = HandsomeFencer::CircleCI::Crypto.new(environment: environment)
@@ -1,6 +1,7 @@
1
- FROM ruby:2.5.3-alpine
1
+ FROM ruby:2.5-alpine
2
+
3
+ LABEL maintainer=<%= config[:email] %>
2
4
 
3
- LABEL maintainer="your-email-here@gmail.com"
4
5
 
5
6
  RUN apk add --no-cache --update build-base linux-headers \
6
7
  postgresql-dev nodejs tzdata libxml2-dev libxslt-dev imagemagick
@@ -11,10 +11,10 @@ RUN mkdir log
11
11
  COPY public public/
12
12
 
13
13
  # Copy Nginx config template
14
- COPY docker/containers/web/app.conf /tmp/docker_example.nginx
14
+ COPY docker/containers/web/app.conf /tmp/<%= config[:app_name] %>.nginx
15
15
 
16
16
  # substitute variable references in the Nginx config template for real values from the environment
17
17
 
18
18
  # put the final config in its place
19
19
 
20
- RUN envsubst '$RAILS_ROOT' < /tmp/docker_example.nginx > /etc/nginx/conf.d/default.conf
20
+ RUN envsubst '$RAILS_ROOT' < /tmp/<%= config[:app_name] %>.nginx > /etc/nginx/conf.d/default.conf
@@ -1,5 +1,5 @@
1
1
  module HandsomeFencer
2
2
  module CircleCI
3
- VERSION = '0.1.38'
3
+ VERSION = '0.1.39'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handsome_fencer-circle_c_i
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.38
4
+ version: 0.1.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - schadenfred
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2018-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sshkit
@@ -144,12 +144,12 @@ files:
144
144
  - lib/handsome_fencer/circle_c_i/templates/config.yml
145
145
  - lib/handsome_fencer/circle_c_i/templates/config/database.yml
146
146
  - lib/handsome_fencer/circle_c_i/templates/docker-compose.yml
147
- - lib/handsome_fencer/circle_c_i/templates/docker/containers/app/Dockerfile
147
+ - lib/handsome_fencer/circle_c_i/templates/docker/containers/app/Dockerfile.tt
148
148
  - lib/handsome_fencer/circle_c_i/templates/docker/containers/app/development.env
149
149
  - lib/handsome_fencer/circle_c_i/templates/docker/containers/app/production.env
150
150
  - lib/handsome_fencer/circle_c_i/templates/docker/containers/database/development.env
151
151
  - lib/handsome_fencer/circle_c_i/templates/docker/containers/database/production.env
152
- - lib/handsome_fencer/circle_c_i/templates/docker/containers/web/Dockerfile
152
+ - lib/handsome_fencer/circle_c_i/templates/docker/containers/web/Dockerfile.tt
153
153
  - lib/handsome_fencer/circle_c_i/templates/docker/containers/web/app.conf
154
154
  - lib/handsome_fencer/circle_c_i/templates/docker/containers/web/development.env
155
155
  - lib/handsome_fencer/circle_c_i/templates/docker/containers/web/production.env
@@ -160,9 +160,8 @@ files:
160
160
  - lib/handsome_fencer/circle_c_i/templates/docker/keys/circleci.key
161
161
  - lib/handsome_fencer/circle_c_i/templates/docker/keys/development.key
162
162
  - lib/handsome_fencer/circle_c_i/templates/docker/keys/production.key
163
- - lib/handsome_fencer/circle_c_i/templates/docker/overrides/docker-compose.circleci.yml
164
- - lib/handsome_fencer/circle_c_i/templates/docker/overrides/docker-compose.production.yml
165
- - lib/handsome_fencer/circle_c_i/templates/docker/overrides/production.docker-compose.yml
163
+ - lib/handsome_fencer/circle_c_i/templates/docker/overrides/circleci.yml.tt
164
+ - lib/handsome_fencer/circle_c_i/templates/docker/overrides/production.yml.tt
166
165
  - lib/handsome_fencer/circle_c_i/templates/docker/web/Dockerfile
167
166
  - lib/handsome_fencer/circle_c_i/templates/docker/web/app.conf
168
167
  - lib/handsome_fencer/circle_c_i/templates/gitignore
@@ -1,44 +0,0 @@
1
- version: '3.1'
2
-
3
- services:
4
-
5
- app:
6
- image: rennmappe/recallapi_app:$DEPLOY_TAG
7
- secrets:
8
- - host_ssh_key
9
- command: [ "bundle", "exec", "puma", "-C", "config/puma.rb" ]
10
-
11
- depends_on:
12
- - database
13
-
14
- volumes:
15
- - app-data:/recallapi
16
- env_file:
17
- - docker/containers/app/production.env
18
- - docker/containers/database/production.env
19
- expose:
20
- - '3000'
21
-
22
- database:
23
- image: postgres
24
- env_file:
25
- - docker/containers/database/production.env
26
-
27
- volumes:
28
- - db-data:/var/lib/postgresql/data
29
-
30
- web:
31
- image: rennmappe/recallapi_web:$DEPLOY_TAG
32
- command: [ "nginx", "-g", "daemon off;" ]
33
- depends_on:
34
- - app
35
- ports:
36
- - "80:80"
37
-
38
- volumes:
39
- db-data:
40
- app-data:
41
-
42
- secrets:
43
- host_ssh_key:
44
- file: ~/.ssh/id_rsa