Skip to content

Commit 6de8091

Browse files
committed
Add Deployment tools
1 parent 63153b7 commit 6de8091

22 files changed

+2054
-0
lines changed

.gitlab-ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
image: ruby:2.7.1-slim-buster
2+
3+
stages:
4+
- Testing Application
5+
- Deploy Staging
6+
- Deploy Production
7+
8+
### VARIABLES ###
9+
variables:
10+
ENV_STAGING: "staging"
11+
ENV_PRODUCTION: "production"
12+
MYSQL_DATABASE: "laravel"
13+
MYSQL_ROOT_PASSWORD: "secret"
14+
MYSQL_PASSWORD: "secret"
15+
16+
.preparation: &preparation
17+
### SETUP SSH ###
18+
- apt-get update -qq
19+
- apt-get install -qq git build-essential
20+
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
21+
- mkdir -p ~/.ssh
22+
- echo "${MYAPP_SSH_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
23+
- echo "${MYAPP_KNOWN_HOSTS}" | tr -d '\r' > ~/.ssh/known_hosts
24+
- chmod 700 ~/.ssh/id_rsa
25+
- eval "$(ssh-agent -s)"
26+
- ssh-add ~/.ssh/id_rsa
27+
- ssh-keyscan -H 'gitlab.com' >> ~/.ssh/known_hosts
28+
- chmod 644 ~/.ssh/known_hosts
29+
### INSTALL LIBRARY ###
30+
- gem install bundler
31+
- bundle install
32+
33+
.run_test: &run_test
34+
- cp src/.env.pipeline.gitlab src/.env
35+
- make fixing-cache
36+
- make composer-install-cicd
37+
- make key-generate
38+
- make composer-dumpautoload
39+
- make run-migrate-all
40+
- make clear-all
41+
42+
.run_staging: &run_staging
43+
- make deploy-staging
44+
45+
.run_production: &run_production
46+
- make deploy-production
47+
48+
.synchronize_staging: &synchronize_staging
49+
- make synchronize-staging
50+
51+
.synchronize_production: &synchronize_production
52+
- make synchronize-production
53+
54+
unit_test_staging:
55+
image: edbizarro/gitlab-ci-pipeline-php:7.4-alpine
56+
environment: ${ENV_STAGING}
57+
stage: Testing Application
58+
services:
59+
- mariadb:10.3.11
60+
script:
61+
- *run_test
62+
only:
63+
- dev-staging
64+
65+
unit_test_production:
66+
image: edbizarro/gitlab-ci-pipeline-php:7.4-alpine
67+
environment: ${ENV_PRODUCTION}
68+
stage: Testing Application
69+
services:
70+
- mariadb:10.3.11
71+
script:
72+
- *run_test
73+
only:
74+
- dev-master
75+
76+
deploy_staging:
77+
environment: ${ENV_STAGING}
78+
stage: Deploy Staging
79+
before_script:
80+
- *preparation
81+
script:
82+
- *run_staging
83+
when: manual
84+
only:
85+
- dev-master
86+
- dev-staging
87+
88+
deploy_production:
89+
environment: ${ENV_PRODUCTION}
90+
stage: Deploy Production
91+
before_script:
92+
- *preparation
93+
script:
94+
- *run_production
95+
when: manual
96+
only:
97+
- dev-master

Capfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Load DSL and set up stages
2+
require "capistrano/setup"
3+
4+
# Include default deployment tasks
5+
require "capistrano/deploy"
6+
7+
# Sudoers Service
8+
require "sshkit/sudo"
9+
10+
# Load the SCM plugin appropriate to your project:
11+
#
12+
# require "capistrano/scm/hg"
13+
# install_plugin Capistrano::SCM::Hg
14+
# or
15+
# require "capistrano/scm/svn"
16+
# install_plugin Capistrano::SCM::Svn
17+
# or
18+
require "capistrano/scm/git"
19+
install_plugin Capistrano::SCM::Git
20+
21+
# Include tasks from other gems included in your Gemfile
22+
#
23+
# For documentation on these, see for example:
24+
#
25+
# https://github.com/capistrano/rvm
26+
# https://github.com/capistrano/rbenv
27+
# https://github.com/capistrano/chruby
28+
# https://github.com/capistrano/bundler
29+
# https://github.com/capistrano/rails
30+
# https://github.com/capistrano/passenger
31+
#
32+
# require "capistrano/rvm"
33+
# require "capistrano/rbenv"
34+
# require "capistrano/chruby"
35+
# require "capistrano/bundler"
36+
# require "capistrano/rails/assets"
37+
# require "capistrano/rails/migrations"
38+
# require "capistrano/passenger"
39+
40+
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
41+
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

Gemfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
source 'https://rubygems.org'
2+
3+
group :development do
4+
gem 'capistrano', '~> 3.11.2'
5+
gem 'capistrano-rvm', '~> 0.1.2'
6+
end
7+
8+
group :development, :test do
9+
gem 'capistrano-sidekiq', '~> 2.0.0.beta2', github: 'seuros/capistrano-sidekiq'
10+
gem 'sshkit-sudo', '~> 0.1.0'
11+
end
12+
13+
group :test do
14+
gem 'minitest', '~> 5.13.0'
15+
end

Gemfile.lock

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
GIT
2+
remote: https://github.com/seuros/capistrano-sidekiq.git
3+
revision: 493ade199ab357ef619f8c7bb4a2bdd8bf653598
4+
specs:
5+
capistrano-sidekiq (2.0.0.beta5)
6+
capistrano (>= 3.9.0)
7+
capistrano-bundler
8+
sidekiq (>= 6.0)
9+
10+
GEM
11+
remote: https://rubygems.org/
12+
specs:
13+
airbrussh (1.4.0)
14+
sshkit (>= 1.6.1, != 1.7.0)
15+
capistrano (3.11.2)
16+
airbrussh (>= 1.0.0)
17+
i18n
18+
rake (>= 10.0.0)
19+
sshkit (>= 1.9.0)
20+
capistrano-bundler (2.0.1)
21+
capistrano (~> 3.1)
22+
capistrano-rvm (0.1.2)
23+
capistrano (~> 3.0)
24+
sshkit (~> 1.2)
25+
concurrent-ruby (1.1.7)
26+
connection_pool (2.2.3)
27+
i18n (1.8.5)
28+
concurrent-ruby (~> 1.0)
29+
minitest (5.13.0)
30+
net-scp (3.0.0)
31+
net-ssh (>= 2.6.5, < 7.0.0)
32+
net-ssh (6.1.0)
33+
rack (2.2.3)
34+
rake (13.0.1)
35+
redis (4.2.2)
36+
sidekiq (6.1.2)
37+
connection_pool (>= 2.2.2)
38+
rack (~> 2.0)
39+
redis (>= 4.2.0)
40+
sshkit (1.21.0)
41+
net-scp (>= 1.1.2)
42+
net-ssh (>= 2.8.0)
43+
sshkit-sudo (0.1.0)
44+
sshkit (~> 1.8)
45+
46+
PLATFORMS
47+
ruby
48+
49+
DEPENDENCIES
50+
capistrano (~> 3.11.2)
51+
capistrano-rvm (~> 0.1.2)
52+
capistrano-sidekiq (~> 2.0.0.beta2)!
53+
minitest (~> 5.13.0)
54+
sshkit-sudo (~> 0.1.0)
55+
56+
BUNDLED WITH
57+
2.1.4

0 commit comments

Comments
 (0)