handsome_fencer-circle_c_i 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +2 -1
- data/bin/handsome_fencer-circle_c_i +1 -1
- data/lib/handsome_fencer/circle_c_i.rb +4 -2
- data/lib/handsome_fencer/circle_c_i/cli.rb +10 -21
- data/lib/handsome_fencer/circle_c_i/cli/expose.rb +14 -0
- data/lib/handsome_fencer/circle_c_i/cli/generate_key.rb +20 -0
- data/lib/handsome_fencer/circle_c_i/cli/install.rb +20 -0
- data/lib/handsome_fencer/circle_c_i/cli/obfuscate.rb +17 -0
- data/lib/handsome_fencer/circle_c_i/crypto.rb +9 -5
- data/lib/handsome_fencer/circle_c_i/templates/Gemfile +2 -0
- data/lib/handsome_fencer/circle_c_i/templates/Gemfile.lock +0 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/circle.env +9 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/config.yml +62 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/containers/app/Dockerfile +11 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/containers/app/development.env +9 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/containers/app/production.env +9 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/containers/app/staging.env +9 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/containers/database/development.env +2 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/containers/database/production.env +2 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/containers/database/staging.env +2 -0
- data/lib/handsome_fencer/circle_c_i/templates/circleci/overrides/production.yml +46 -0
- data/lib/handsome_fencer/circle_c_i/templates/config/database.yml +20 -0
- data/lib/handsome_fencer/circle_c_i/templates/docker-compose.yml +77 -0
- data/lib/handsome_fencer/circle_c_i/templates/lib/tasks/deploy.rake +99 -0
- data/lib/handsome_fencer/circle_c_i/version.rb +1 -1
- metadata +22 -18
- data/lib/handsome_fencer/circle_c_i/cli/hn.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2acf42c963b88c0fef32cb3a6eca20fd6533ace92423b8edc5736a89d7957788
|
4
|
+
data.tar.gz: 54505ec7ecf23aa788e72a845070222b3668b69d2d32728e15928f453d9c6052
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ad35a8d7cbec0e393d6d9a14a49155b55df48b82f58cc4f86a3ee9986a621cf1d5d6fc3005777335ad70b75ad4f863da8059ba475e2030acdc7a0a2a36e5c46
|
7
|
+
data.tar.gz: 1b3108b65aab6f0f26c4002d2927660448edf994c6096ee0c9f746a2084e82fe6c587a3af4b80fb124fa0bd6b37cff98a00d000448ab67b5885fe4d39b834b5a
|
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
# require "handsome_fencer/circle_c_i/railtie"
|
2
1
|
require "handsome_fencer/circle_c_i/version"
|
3
2
|
require "handsome_fencer/circle_c_i/cli"
|
3
|
+
require "handsome_fencer/circle_c_i/cli/install"
|
4
4
|
require "handsome_fencer/circle_c_i/crypto"
|
5
5
|
|
6
6
|
module HandsomeFencer
|
7
7
|
module CircleCI
|
8
|
-
#
|
8
|
+
# module Cli
|
9
|
+
# Your code goes here..
|
10
|
+
# end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,31 +1,20 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'handsome_fencer/circle_c_i/cli/
|
2
|
+
require 'handsome_fencer/circle_c_i/cli/install'
|
3
|
+
require 'handsome_fencer/circle_c_i/cli/generate_key'
|
4
|
+
require 'handsome_fencer/circle_c_i/cli/generate_key'
|
5
|
+
require 'handsome_fencer/circle_c_i/cli/obfuscate'
|
6
|
+
require 'handsome_fencer/circle_c_i/cli/expose'
|
7
|
+
require 'byebug'
|
3
8
|
|
4
9
|
module HandsomeFencer
|
5
10
|
module CircleCI
|
6
|
-
class
|
7
|
-
desc "hello NAME", "This will greet you"
|
8
|
-
long_desc <<-HELLO_WORLD
|
11
|
+
class CLI < Thor
|
9
12
|
|
10
|
-
|
13
|
+
include Thor::Actions
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
developed by Martin Richards. BCPL was used while C was being
|
15
|
-
developed at Bell Labs a few years before the publication of
|
16
|
-
Kernighan and Ritchie's C book in 1972.
|
17
|
-
|
18
|
-
http://stackoverflow.com/a/12785204
|
19
|
-
HELLO_WORLD
|
20
|
-
option :upcase
|
21
|
-
def hello( name )
|
22
|
-
greeting = "Hello, #{name}"
|
23
|
-
greeting.upcase! if options[:upcase]
|
24
|
-
puts greeting
|
15
|
+
def self.source_root
|
16
|
+
File.dirname(__FILE__) + '/templates/'
|
25
17
|
end
|
26
|
-
|
27
|
-
desc "hn COMMANDS", "Hacker News Control Module"
|
28
|
-
subcommand "hn", HandsomeFencer::CircleCI::CLI::Hn
|
29
18
|
end
|
30
19
|
end
|
31
20
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module HandsomeFencer
|
2
|
+
module CircleCI
|
3
|
+
class CLI < Thor
|
4
|
+
|
5
|
+
desc "expose", "expose .env files inside .circleci directory"
|
6
|
+
|
7
|
+
def expose(*args)
|
8
|
+
environment = args.first
|
9
|
+
@cipher = HandsomeFencer::CircleCI::Crypto.new(environment: environment)
|
10
|
+
@cipher.expose('.circleci', "#{environment}.env.enc")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'byebug'
|
2
|
+
|
3
|
+
module HandsomeFencer
|
4
|
+
module CircleCI
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
desc "generate_key", "(Re)generate a key for each environment"
|
8
|
+
|
9
|
+
def generate_key(*args)
|
10
|
+
environment = args.first ? args.first : "deploy"
|
11
|
+
|
12
|
+
@cipher = OpenSSL::Cipher.new 'AES-128-CBC'
|
13
|
+
@salt = '8 octets'
|
14
|
+
@new_key = @cipher.random_key
|
15
|
+
|
16
|
+
create_file ".circleci/keys/#{environment}.key", Base64.encode64(@new_key)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module HandsomeFencer
|
2
|
+
module CircleCI
|
3
|
+
class CLI < Thor
|
4
|
+
|
5
|
+
desc "install", "This will generate a .circleci directory in your project root, along with a set of files for continuous deployments using docker and CircleCI"
|
6
|
+
|
7
|
+
def install
|
8
|
+
directory "circleci", "./.circleci", recursive: true
|
9
|
+
directory 'lib/', 'lib', recursive: true
|
10
|
+
copy_file "docker-compose.yml", "docker-compose.yml"
|
11
|
+
copy_file "Gemfile", "Gemfile"
|
12
|
+
copy_file "Gemfile.lock", "Gemfile.lock"
|
13
|
+
copy_file "config/database.yml", "config/database.yml"
|
14
|
+
create_file '.gitignore' unless File.exist? '.gitignore'
|
15
|
+
append_to_file '.gitignore', "\n.circleci/**/*.env"
|
16
|
+
append_to_file '.gitignore', "\n.circleci/**/*.key"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'byebug'
|
2
|
+
|
3
|
+
module HandsomeFencer
|
4
|
+
module CircleCI
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
desc "obfuscate", "obfuscate .env files inside .circleci directory"
|
8
|
+
|
9
|
+
def obfuscate(*args)
|
10
|
+
|
11
|
+
environment = args.first
|
12
|
+
@cipher = HandsomeFencer::CircleCI::Crypto.new(environment: environment)
|
13
|
+
@cipher.obfuscate('.circleci', "#{environment}.env")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -10,18 +10,21 @@ module HandsomeFencer
|
|
10
10
|
def initialize(options={})
|
11
11
|
@cipher = OpenSSL::Cipher.new 'AES-128-CBC'
|
12
12
|
@salt = '8 octets'
|
13
|
-
@dkfile =
|
13
|
+
@dkfile = '.circleci/keys/' + options[:environment] + '.key'
|
14
|
+
@deploy_key = (options[:environment] + '_key').upcase
|
14
15
|
@pass_phrase = get_deploy_key
|
15
16
|
end
|
16
17
|
|
17
18
|
def get_deploy_key
|
18
19
|
case
|
19
|
-
when ENV[
|
20
|
-
raise DeployKeyError, "No
|
20
|
+
when ENV[@deploy_key].nil? && !File.exist?(@dkfile)
|
21
|
+
raise DeployKeyError, "No #{@deploy_key} set. Please generate using '$ handsome_fencer-circle_c_i generate_key :circle' or '$ export
|
22
|
+
ENV['CIRCLE_KEY'] = some-complicated-key'"
|
21
23
|
when File.exist?(@dkfile)
|
22
24
|
Base64.decode64(File.read(@dkfile))
|
23
|
-
when !ENV[
|
24
|
-
|
25
|
+
when !ENV[@deploy_key].nil?
|
26
|
+
|
27
|
+
Base64.decode64(ENV[@deploy_key])
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -68,6 +71,7 @@ module HandsomeFencer
|
|
68
71
|
end
|
69
72
|
|
70
73
|
def obfuscate(directory=nil, extension=nil)
|
74
|
+
|
71
75
|
extension = extension || '.env'
|
72
76
|
directory = directory || '.circleci'
|
73
77
|
source_files(directory, extension).each { |file| encrypt file }
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
DOCKERHUB_PASS="set me"
|
2
|
+
DOCKERHUB_EMAIL="set me"
|
3
|
+
DOCKERHUB_USER="set me"
|
4
|
+
PUSH_DEPLOY_TAG=${CIRCLE_PREVIOUS_BUILD_NUM}_${CIRCLE_SHA1:0:7}
|
5
|
+
DEPLOY_TAG=${CIRCLE_BUILD_NUM}_${CIRCLE_SHA1:0:7}
|
6
|
+
DEPLOY_PATH="name of our app"
|
7
|
+
SERVER_HOST="server ip address"
|
8
|
+
SERVER_USER="probably root"
|
9
|
+
SERVER_PORT="probably 22"
|
@@ -0,0 +1,62 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
working_directory: /tmp
|
3
|
+
|
4
|
+
version: 2
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
|
8
|
+
build:
|
9
|
+
machine: true
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- run: gem install handsome_fencer-circle_c_i
|
13
|
+
- run: ruby .circleci/expose_env.rb
|
14
|
+
- run: docker-compose build dev_app database
|
15
|
+
- run: docker-compose run dev_app bin/rails db:create db:migrate test
|
16
|
+
|
17
|
+
push:
|
18
|
+
docker:
|
19
|
+
- image: circleci/ruby:2.5.1-node-browsers
|
20
|
+
environment:
|
21
|
+
BASH_ENV: .env/circle/deploy.env
|
22
|
+
steps:
|
23
|
+
- checkout
|
24
|
+
- setup_remote_docker
|
25
|
+
- run: gem install handsomefencer-environment
|
26
|
+
- run: ruby expose_env.rb
|
27
|
+
- run: docker-compose up -d --build
|
28
|
+
- run:
|
29
|
+
name: Tag web image
|
30
|
+
command: docker tag $(docker images | grep project_web | awk '{ print $3 }') rennmappe/bacchanal_web:$DEPLOY_TAG
|
31
|
+
- run: docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
|
32
|
+
- run: docker push rennmappe/bacchanal_web:$DEPLOY_TAG
|
33
|
+
|
34
|
+
deploy:
|
35
|
+
docker:
|
36
|
+
- image: circleci/ruby:2.5.1-node-browsers
|
37
|
+
environment:
|
38
|
+
BASH_ENV: .env/circle/deploy.env
|
39
|
+
steps:
|
40
|
+
- checkout
|
41
|
+
- add_ssh_keys
|
42
|
+
- run: bundle install --without production
|
43
|
+
- run: ruby expose_env.rb
|
44
|
+
- run: bin/rails docker:deploy
|
45
|
+
|
46
|
+
workflows:
|
47
|
+
version: 2
|
48
|
+
build-and-deploy:
|
49
|
+
jobs:
|
50
|
+
- build
|
51
|
+
- push:
|
52
|
+
requires:
|
53
|
+
- build
|
54
|
+
filters:
|
55
|
+
branches:
|
56
|
+
only: master
|
57
|
+
- deploy:
|
58
|
+
requires:
|
59
|
+
- push
|
60
|
+
filters:
|
61
|
+
branches:
|
62
|
+
only: master
|
@@ -0,0 +1,11 @@
|
|
1
|
+
FROM ruby:2.5-alpine
|
2
|
+
|
3
|
+
LABEL maintainer="your-email-here@gmail.com"
|
4
|
+
|
5
|
+
RUN apk add --no-cache --update build-base linux-headers \
|
6
|
+
postgresql-dev nodejs tzdata libxml2-dev libxslt-dev
|
7
|
+
|
8
|
+
COPY Gemfile* /usr/src/app/
|
9
|
+
WORKDIR /usr/src/app
|
10
|
+
RUN bundle install
|
11
|
+
COPY . /usr/src/app/
|
@@ -0,0 +1,9 @@
|
|
1
|
+
DOCKERHUB_PASS="set me"
|
2
|
+
DOCKERHUB_EMAIL="set me"
|
3
|
+
DOCKERHUB_USER="set me"
|
4
|
+
PUSH_DEPLOY_TAG=${CIRCLE_PREVIOUS_BUILD_NUM}_${CIRCLE_SHA1:0:7}
|
5
|
+
DEPLOY_TAG=${CIRCLE_BUILD_NUM}_${CIRCLE_SHA1:0:7}
|
6
|
+
DEPLOY_PATH="name of our app"
|
7
|
+
SERVER_HOST="server ip address"
|
8
|
+
SERVER_USER="probably root"
|
9
|
+
SERVER_PORT="probably 22"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
DOCKERHUB_PASS="set me"
|
2
|
+
DOCKERHUB_EMAIL="set me"
|
3
|
+
DOCKERHUB_USER="set me"
|
4
|
+
PUSH_DEPLOY_TAG=${CIRCLE_PREVIOUS_BUILD_NUM}_${CIRCLE_SHA1:0:7}
|
5
|
+
DEPLOY_TAG=${CIRCLE_BUILD_NUM}_${CIRCLE_SHA1:0:7}
|
6
|
+
DEPLOY_PATH="name of our app"
|
7
|
+
SERVER_HOST="server ip address"
|
8
|
+
SERVER_USER="probably root"
|
9
|
+
SERVER_PORT="probably 22"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
DOCKERHUB_PASS="set me"
|
2
|
+
DOCKERHUB_EMAIL="set me"
|
3
|
+
DOCKERHUB_USER="set me"
|
4
|
+
PUSH_DEPLOY_TAG=${CIRCLE_PREVIOUS_BUILD_NUM}_${CIRCLE_SHA1:0:7}
|
5
|
+
DEPLOY_TAG=${CIRCLE_BUILD_NUM}_${CIRCLE_SHA1:0:7}
|
6
|
+
DEPLOY_PATH="name of our app"
|
7
|
+
SERVER_HOST="server ip address"
|
8
|
+
SERVER_USER="probably root"
|
9
|
+
SERVER_PORT="probably 22"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
version: '3.1'
|
2
|
+
|
3
|
+
services:
|
4
|
+
|
5
|
+
app:
|
6
|
+
image: rennmappe/handsomefencer_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:/handsomefencer
|
16
|
+
environment:
|
17
|
+
- RAILS_MASTER_KEY
|
18
|
+
env_file:
|
19
|
+
- .env/development/database.env
|
20
|
+
- .env/development/app.env
|
21
|
+
expose:
|
22
|
+
- '3000'
|
23
|
+
|
24
|
+
database:
|
25
|
+
image: postgres
|
26
|
+
env_file:
|
27
|
+
- .env/development/database.env
|
28
|
+
|
29
|
+
volumes:
|
30
|
+
- db-data:/var/lib/postgresql/data
|
31
|
+
|
32
|
+
web:
|
33
|
+
image: rennmappe/handsomefencer_web:$DEPLOY_TAG
|
34
|
+
command: [ "nginx", "-g", "daemon off;" ]
|
35
|
+
depends_on:
|
36
|
+
- app
|
37
|
+
ports:
|
38
|
+
- "80:80"
|
39
|
+
|
40
|
+
volumes:
|
41
|
+
db-data:
|
42
|
+
app-data:
|
43
|
+
|
44
|
+
secrets:
|
45
|
+
host_ssh_key:
|
46
|
+
file: ~/.ssh/id_rsa
|
@@ -0,0 +1,20 @@
|
|
1
|
+
default: &default
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
host: <%= ENV.fetch('DATABASE_HOST') %>
|
5
|
+
username: <%= ENV.fetch('POSTGRES_USER') %>
|
6
|
+
password: <%= ENV.fetch('POSTGRES_PASSWORD') %>
|
7
|
+
database: <%= ENV.fetch('POSTGRES_DB') %>
|
8
|
+
pool: 5
|
9
|
+
variables:
|
10
|
+
statement_timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
|
15
|
+
test:
|
16
|
+
<<: *default
|
17
|
+
|
18
|
+
|
19
|
+
production:
|
20
|
+
<<: *default
|
@@ -0,0 +1,77 @@
|
|
1
|
+
version: '3.1'
|
2
|
+
|
3
|
+
services:
|
4
|
+
|
5
|
+
dev_app:
|
6
|
+
build:
|
7
|
+
context: .
|
8
|
+
dockerfile: ./docker/app/Dockerfile
|
9
|
+
|
10
|
+
depends_on:
|
11
|
+
- database
|
12
|
+
ports:
|
13
|
+
- "35729:35729"
|
14
|
+
- "3000:3000"
|
15
|
+
volumes:
|
16
|
+
- .:/usr/src/app
|
17
|
+
- gem_cache:/gems
|
18
|
+
env_file:
|
19
|
+
- .env/development/database.env
|
20
|
+
- .env/development/app.env
|
21
|
+
command: [ "bin/rails", "s" ]
|
22
|
+
|
23
|
+
stdin_open: true
|
24
|
+
tty: true
|
25
|
+
secrets:
|
26
|
+
- host_ssh_key
|
27
|
+
|
28
|
+
app:
|
29
|
+
|
30
|
+
build:
|
31
|
+
context: .
|
32
|
+
dockerfile: ./docker/app/Dockerfile
|
33
|
+
|
34
|
+
depends_on:
|
35
|
+
- database
|
36
|
+
ports:
|
37
|
+
- "3000:3000"
|
38
|
+
volumes:
|
39
|
+
- .:/usr/src/app
|
40
|
+
- gem_cache:/gems
|
41
|
+
environment:
|
42
|
+
- RAILS_ENV=production
|
43
|
+
env_file:
|
44
|
+
- .env/development/database.env
|
45
|
+
- .env/development/app.env
|
46
|
+
|
47
|
+
command: [ "bundle", "exec", "puma", "-C", "config/puma.rb" ]
|
48
|
+
|
49
|
+
secrets:
|
50
|
+
- host_ssh_key
|
51
|
+
|
52
|
+
web:
|
53
|
+
build:
|
54
|
+
context: .
|
55
|
+
dockerfile: ./docker/web/Dockerfile
|
56
|
+
command: [ "nginx", "-g", "daemon off;" ]
|
57
|
+
|
58
|
+
depends_on:
|
59
|
+
- app
|
60
|
+
expose:
|
61
|
+
- 80
|
62
|
+
|
63
|
+
database:
|
64
|
+
image: postgres
|
65
|
+
env_file:
|
66
|
+
- .env/development/database.env
|
67
|
+
|
68
|
+
volumes:
|
69
|
+
- db-data:/var/lib/postgresql/data
|
70
|
+
|
71
|
+
volumes:
|
72
|
+
db-data:
|
73
|
+
gem_cache:
|
74
|
+
|
75
|
+
secrets:
|
76
|
+
host_ssh_key:
|
77
|
+
file: ~/.ssh/id_rsa
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# use SSHKit directly instead of Capistrano
|
2
|
+
require 'sshkit'
|
3
|
+
require 'sshkit/dsl'
|
4
|
+
include SSHKit::DSL
|
5
|
+
|
6
|
+
deploy_tag = ENV['DEPLOY_TAG']
|
7
|
+
hostname = ENV['SERVER_HOST']
|
8
|
+
user = ENV['SERVER_USER']
|
9
|
+
dockerhub_user = ENV['DOCKERHUB_USER']
|
10
|
+
dockerhub_pass = ENV['DOCKERHUB_PASS']
|
11
|
+
port = ENV['SERVER_PORT']
|
12
|
+
deploy_env = ENV['DEPLOY_ENV'] || :production
|
13
|
+
deploy_path = ENV['DEPLOY_PATH']
|
14
|
+
|
15
|
+
server = SSHKit::Host.new(hostname: hostname, port: port, user: user)
|
16
|
+
|
17
|
+
namespace :deploy do
|
18
|
+
|
19
|
+
desc 'copy to server files needed to run and manage Docker containers'
|
20
|
+
|
21
|
+
task :configs do
|
22
|
+
|
23
|
+
on server do
|
24
|
+
within deploy_path do
|
25
|
+
upload! File.expand_path('../../config/containers/docker-compose.yml', __dir__), '.'
|
26
|
+
upload! File.expand_path('../../.env', __dir__), '.', recursive: true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
namespace :docker do
|
34
|
+
|
35
|
+
desc 'logs into Docker Hub for pushing and pulling'
|
36
|
+
|
37
|
+
task :login do
|
38
|
+
on server do
|
39
|
+
execute "mkdir -p #{deploy_path}"
|
40
|
+
within deploy_path do
|
41
|
+
execute 'docker', 'login', '-u', dockerhub_user, '-p', dockerhub_pass
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'stops all Docker containers via Docker Compose'
|
47
|
+
|
48
|
+
task stop: 'deploy:configs' do
|
49
|
+
on server do
|
50
|
+
within deploy_path do
|
51
|
+
with rails_env: deploy_env, deploy_tag: deploy_tag do
|
52
|
+
execute 'docker-compose', 'stop'
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'starts all Docker containers via Docker Compose'
|
60
|
+
|
61
|
+
task start: 'deploy:configs' do
|
62
|
+
on server do
|
63
|
+
within deploy_path do
|
64
|
+
with rails_env: deploy_env, deploy_tag: deploy_tag do
|
65
|
+
execute 'docker-compose', 'up', '-d'
|
66
|
+
execute 'echo', deploy_tag , '>', 'deploy.tag'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'pulls images from Docker Hub'
|
73
|
+
|
74
|
+
task pull: 'docker:login' do
|
75
|
+
on server do
|
76
|
+
within deploy_path do
|
77
|
+
["#{deploy_path}_app", "#{deploy_path}_web"].each do |image_name|
|
78
|
+
execute 'docker', 'pull', "rennmappe/#{image_name}:#{deploy_tag}"
|
79
|
+
end
|
80
|
+
execute 'docker', 'pull', 'postgres:9.4.5'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
desc 'runs database migrations in application container via Docker Compose'
|
87
|
+
task migrate: 'deploy:configs' do
|
88
|
+
on server do
|
89
|
+
within deploy_path do
|
90
|
+
with rails_env: deploy_env, deploy_tag: deploy_tag do
|
91
|
+
execute 'docker-compose', 'run', 'app', "bin/rails", 'db:create', 'db:migrate'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
desc 'pulls images, stops old containers, updates the database, and starts new containers'
|
98
|
+
task deploy: %w{docker:pull docker:stop docker:migrate docker:start }
|
99
|
+
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.
|
4
|
+
version: 0.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- schadenfred
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sshkit
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: sqlite3
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: minitest-given
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,12 +114,30 @@ files:
|
|
128
114
|
- lib/handsome_fencer/circle_c_i.rb
|
129
115
|
- lib/handsome_fencer/circle_c_i/Rakefile
|
130
116
|
- lib/handsome_fencer/circle_c_i/cli.rb
|
131
|
-
- lib/handsome_fencer/circle_c_i/cli/
|
117
|
+
- lib/handsome_fencer/circle_c_i/cli/expose.rb
|
118
|
+
- lib/handsome_fencer/circle_c_i/cli/generate_key.rb
|
119
|
+
- lib/handsome_fencer/circle_c_i/cli/install.rb
|
120
|
+
- lib/handsome_fencer/circle_c_i/cli/obfuscate.rb
|
132
121
|
- lib/handsome_fencer/circle_c_i/crypto.rb
|
133
122
|
- lib/handsome_fencer/circle_c_i/generators/install_generator.rb
|
134
123
|
- lib/handsome_fencer/circle_c_i/tasks/generate_key.rake
|
135
124
|
- lib/handsome_fencer/circle_c_i/tasks/install.rake
|
136
125
|
- lib/handsome_fencer/circle_c_i/tasks/obfuscate.rake
|
126
|
+
- lib/handsome_fencer/circle_c_i/templates/Gemfile
|
127
|
+
- lib/handsome_fencer/circle_c_i/templates/Gemfile.lock
|
128
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/circle.env
|
129
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/config.yml
|
130
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/containers/app/Dockerfile
|
131
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/containers/app/development.env
|
132
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/containers/app/production.env
|
133
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/containers/app/staging.env
|
134
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/containers/database/development.env
|
135
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/containers/database/production.env
|
136
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/containers/database/staging.env
|
137
|
+
- lib/handsome_fencer/circle_c_i/templates/circleci/overrides/production.yml
|
138
|
+
- lib/handsome_fencer/circle_c_i/templates/config/database.yml
|
139
|
+
- lib/handsome_fencer/circle_c_i/templates/docker-compose.yml
|
140
|
+
- lib/handsome_fencer/circle_c_i/templates/lib/tasks/deploy.rake
|
137
141
|
- lib/handsome_fencer/circle_c_i/version.rb
|
138
142
|
homepage: https://github.com/schadenfred/handsome_fencer-circle_c_i
|
139
143
|
licenses:
|
@@ -158,5 +162,5 @@ rubyforge_project:
|
|
158
162
|
rubygems_version: 2.7.7
|
159
163
|
signing_key:
|
160
164
|
specification_version: 4
|
161
|
-
summary: Handsome deployment of
|
165
|
+
summary: Handsome deployment of apps using Circle and Docker
|
162
166
|
test_files: []
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module HandsomeFencer
|
2
|
-
module CircleCI
|
3
|
-
module CLI
|
4
|
-
class Hn < Thor
|
5
|
-
desc "search URL", "Search hn.algolia.com for a url mentioned on Hackernews"
|
6
|
-
option :tags
|
7
|
-
def search( url )
|
8
|
-
puts "Looks like you are looking for #{url} with tags #{options[:tags]}"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|