I'm new to Laravel, currently working on my first project. I have worked with CI before but never with Laravel. So, here's my deploy script for our Dev server. Not sure if this is the best approach. Anyway, the migrate part is giving me an error. After I get this to work I will try some php plugins to analyze code quality, duplication, unit tests, etc.
Please, see below
Script:
rsync -a . /var/www/html/dev/
cd /var/www/html/dev/
# cfg file for dev
cp .env.dev .env
# run composer
composer clearcache
composer install --optimize-autoloader
# optimize
php artisan cache:clear
php artisan optimize
php artisan route:cache | true
# migrate DB
php artisan migrate
Error:
[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists:
Am I supposed to delete all my tables before doing the migration? If so, I don't see what's the useful part of using them for auto deployment. Besides, we have our tables filled with data for testing (manually filled as we don't want to auto seed).
You shouldn't delete all your tables before run migration.
This error come from your migrations
table and your migrations
at database\\migrations
folder have conflict.
You should resolve this conflict before return to continue configure Jenkins.
My suggestion:
You should use Rocketeer for control release versions of your projects.
You can share your .env
file by shared
folder.
You can run composer install
and npm install
by default configure of Rocketeer.
Here is my steps install and configure Rocketeer:
Install Rocketeer:
$ wget http://rocketeer.autopergamene.eu/versions/rocketeer.phar
$ chmod +x rocketeer.phar
$ mv rocketeer.phar /usr/local/bin/rocketeer
//TODO Install PHP for Jenkins server
$ sudo apt-get install php
//TODO Check rocketeer
$ rocketeer check
No connections have been set, please create one: (production) <~ Succeed
Setup remote server information
$ cd /var/lib/jenkins/drone-deploy/drone-deploy/server-dev
$ rocketeer ignite
No connections have been set, please create one: (production)develop
No host is set for [develop], please provide one:35.166.x.x
No username is set for [develop], please provide one:ec2-user
No password or SSH key is set for [develop], which would you use? (key) [key/password]key
Please enter the full path to your key (/var/lib/jenkins/.ssh/id_rs/var/lib/jenkins/.ssh/xxx.pem
If a keyphrase is required, provide it
No repository is set for [repository], please provide one:git@bitbucket.org:xx/xxxxxx.git
No username is set for [repository], please provide one:xxx
No password is set for [repository], please provide one:
develop/0 | Ignite (Creates Rocketeer's configuration)
What is your application's name ? (drone-php)drone_deploy
The Rocketeer configuration was created at server-dev/.rocketeer
Configure
$ cd /var/lib/jenkins/drone-deploy/drone-deploy/drone-php
$ nano .rocketeer/config.php
Replace connections name production --> develop //It's Rocketeer bug
$ nano .rocketeer/remote.php
'root_directory' => '/var/www/html/',
'shared' => [
'storage/logs',
'storage/framework/sessions',
'.env',
],
'permissions' => [
// The folders and files to set as web writable
'files' => [
//'app/database/production.sqlite',
'bootstrap',
'storage',
'public',
],
// Here you can configure what actions will be executed to set
// permissions on the folder above. The Closure can return
// a single command as a string or an array of commands
'callback' => function ($task, $file) {
return [
sprintf('chmod -R 777 %s', $file),
sprintf('chmod -R g+s %s', $file),
sprintf('chown -R ec2-user:ec2-user %s', $file),
];
},
],
$ nano .rocketeer/strategies.php
//'test' => 'Phpunit',
'test' => '',
//return $composer->install([], ['--no-interaction' => null, '--no-dev' => null, '--prefer-dist' => null]);
return $composer->install([]);
Running test
rocketeer deploy --on="develop" --tests
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.