Skip to content

Commit ab2a922

Browse files
committed
Add deployment and migration configs
1 parent c0ccad9 commit ab2a922

File tree

5 files changed

+86
-10
lines changed

5 files changed

+86
-10
lines changed

.env.example

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
PHINX_DB_TYPE={{DB_TYPE}}
2-
PHINX_DB_HOST={{DB_HOST}}
3-
PHINX_DB_NAME={{DB_NAME}}
4-
PHINX_DB_USER={{DB_USER}}
5-
PHINX_DB_PASS={{DB_PASS}}
1+
PHINX_API_LONESTARPHP_DB_TYPE={{DB_TYPE}}
2+
PHINX_API_LONESTARPHP_DB_HOST={{DB_HOST}}
3+
PHINX_API_LONESTARPHP_DB_NAME={{DB_NAME}}
4+
PHINX_API_LONESTARPHP_DB_USER={{DB_USER}}
5+
PHINX_API_LONESTARPHP_DB_PASS={{DB_PASS}}

Capfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Load DSL and Setup Up Stages
2+
require 'capistrano/setup'
3+
4+
# Includes default deployment tasks
5+
require 'capistrano/deploy'
6+
7+
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
8+
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

config/deploy.rb

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# config valid only for Capistrano 3.1
2+
lock '3.2.1'
3+
4+
set :application, 'api.lonestarphp.com'
5+
set :repo_url, 'https://github.com/DallasPHP/lonestarphp-api.git'
6+
7+
# Default branch is :master
8+
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
9+
10+
# Default deploy_to directory is /var/www/my_app
11+
set :deploy_to, '/var/www/api.lonestarphp.com'
12+
13+
# Default value for :scm is :git
14+
set :scm, :git
15+
16+
# Default value for :format is :pretty
17+
set :format, :pretty
18+
19+
# Default value for :log_level is :debug
20+
set :log_level, :debug
21+
22+
# Default value for :pty is false
23+
set :pty, true
24+
25+
# Default value for :linked_files is []
26+
# set :linked_files, %w{}
27+
28+
# Default value for linked_dirs is []
29+
set :linked_dirs, %w{vendor}
30+
31+
# Default value for default_env is {}
32+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
33+
34+
# Default value for keep_releases is 5
35+
set :keep_releases, 5
36+
37+
namespace :deploy do
38+
39+
desc 'Composer Install'
40+
task :composer_install do
41+
on roles(:web) do
42+
within release_path do
43+
execute 'composer', 'install', '--no-dev', '--optimize-autoloader'
44+
end
45+
end
46+
end
47+
48+
desc 'Migrate Database'
49+
task :phinx_migrate do
50+
on roles(:web) do
51+
within release_path do
52+
execute './vendor/bin/phinx', 'migrate', '-e production'
53+
end
54+
end
55+
end
56+
57+
after :publishing, :composer_install
58+
after :publishing, :phinx_migrate
59+
60+
end

config/deploy/production.rb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
role :web, %w{lonestarphp.prod}

phinx.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ environments:
55
default_migration_table: phinxlog
66
default_database: local
77
local:
8-
adapter: %%PHINX_DB_TYPE%%
9-
host: %%PHINX_DB_HOST%%
10-
name: %%PHINX_DB_NAME%%
11-
user: %%PHINX_DB_USER%%
12-
pass: %%PHINX_DB_PASS%%
8+
adapter: %%PHINX_API_LONESTARPHP_DB_TYPE%%
9+
host: %%PHINX_API_LONESTARPHP_DB_HOST%%
10+
name: %%PHINX_API_LONESTARPHP_DB_NAME%%
11+
user: %%PHINX_API_LONESTARPHP_DB_USER%%
12+
pass: %%PHINX_API_LONESTARPHP_DB_PASS%%
13+
charset: utf8
14+
production:
15+
adapter: %%PHINX_API_LONESTARPHP_DB_TYPE%%
16+
host: %%PHINX_API_LONESTARPHP_DB_HOST%%
17+
name: %%PHINX_API_LONESTARPHP_DB_NAME%%
18+
user: %%PHINX_API_LONESTARPHP_DB_USER%%
19+
pass: %%PHINX_API_LONESTARPHP_DB_PASS%%
1320
charset: utf8

0 commit comments

Comments
 (0)