I'm currently building a Laravel 5.1 system, that is being automatically deployed to several servers in several steps (local, test and production).
Unfortunatly I have an issue with the optimized class loader. During deployment, Composer runs and through the composer.json file, the two commands php artisan clear-compiled and php artisan optimize runs without any problems.
My problem is that Laravel at some time during execution of a page tries to write to /bootstrap/cache/services.json, but this fails since the (systemwise) user that created the folder, is not the same as the user that tries to write to the file (It also doesn't make sense that it tries to optimize, since the optimiser file is already created).
Is is possible to disable the "on-the-fly" class loader optimizer? (And if it is, what are the consequenses?)
Before any "You should just change permissions to ...", then i'd like to point out that it is currently not a viable solution. Everything is versionized, so the folder on the server is named something like server/project/20151122192701/laravel and I don't think our tech guys are intersted in changing permissions every time we commit to production :)
I ended up deleting php artisan clear-compiled and php artisan optimize from the composer.json to prevent the commands from running when committing. I also !services.json to /bootstrap/cache/.gitignore (to make it committable) and committing services.json with new writeable permissions (755).
This is to prevent the deploy user from deleting services.json and recreating it with no-write permissions...
I had some other problems with Laravel also caching views and sessions, but this was solved by caching views in the system temp folder (i know this is probably not the best solution, but it works) and using memcached for sessions.
Related
When I deploy a new app to nginx using Capistrano.
I follow tutorial to do git mv database.yml database.yml.example and git mv secrets.yml secrets.yml.example , then created a new database.yml file on remote server. But now when I want to run app on my local mechine, it shows me an error
No such file - ["config/database.yml"]
Because there is no database.yml on my local repo.
Can I create an new and empty database.yml to fix this?
The guide just tells you that storing database credentials in a repository is bad practice and you shouldn't do it, but it doesn't mean you don't need to have this files at all.You application still needs it, so you definitely need to create it, just don't store it in main repo with code, this security critical information is better to store it elsewhere you decide to keep your authentification data like separate repository for credentials, key-pass storage or whatever place you want for such critical information.
PS Of course, if you just learning since it's not a big deal, you COULD keep your "root-123" credits in repository, but it's better to develop right habit from the beginning or at least get the idea why it should be separated.
I'm coming from the world of python, django where usually our deployment flow was as follow:
tar/gz our code release
unpack on the production
Run db migration manually via south
Run the app
Grails is a little bit different than python/django mainly because the end product is a compiled war. My biggest problem is the manual DB migration. I don't want to run it automatically, one suggested solution that I saw is to use dbm-update-sql to generate manual sql file, but in order to produce it I need my local DB to have the same version as the production DB - I don't like it.
any other suggestions ? it looks to me like the only way to run it manually is to deploy yhe source code on the machine and run the dbm commands there.
You can run dbm-update-sql against the production database, it won't make any changes since like all of the -sql scripts it's there to show you what would be done in the event of a real migration. To be safe, create a user that doesn't have permission to make any changes and use that when you run the script. Create a custom environment in DataSource.groovy with that user info and the production connection info and specify that environment when running the script.
I'd highly recommend not deploying the source to your production systems. Since, you want to manually control your database migrations, outside of the normal flow of a Grails application I'd recommend you look at using liquibase as a stand alone tool.
Obviously since you don't want to manage having a copy of your production schema to diff against this is going to be a lot of manual work for you (e.g. keeping your changes up to date).
The database migration plugin can be used to create sql scripts that you manually run, but you do need a production schema to diff against. I'd recommend you head this route, but you seem set against doing so.
I am using dokku-alot to deploy my Rails 4 app to my staging server and everything is working just swell.
One requirement I have with my current project is in regards to seed file data. I've had to keep my seeds.rb file out of version control because of sensitive information. However, I can't figure out how to add the seeds.rb file into the container after a build.
I've tried ssh root#myhost ap_name which gets me into the VM but even if I scp the files into there, the container doesn't see them. How can I drop a few files where my rails code is in the docker image?
Depending on how much information is in your seeds.rb file, you could use environmental variables. This the solution I ended up using.
You basically set the variable: config:set my-app SECRET=whateversupersecretinfo. Then in your code, you can extract that app variable by using ENV['SECRET']. (This works pretty much the same in Heroku) Not sure if that would solve your use case, but leaving this answer here for posterity.
subnote: In Node.js you can extract these variables like process.env.SECRET
To give you some context, I'm trying to use Figaro to safely add in environment variables without having to worry about security risks. The problem is is that I can't seem to get Engine Yard to play nice with production.
I went and did a touch application.yml and then vim application.yml, i, and then command+v to insert that api keys and what not. I know the ENV['VARIABLES'] work because of development and all my rspec and cucumber tests (which utilize the APIs), passed.
When I've got everything ready, I add within the .gitignore:
# Ignore application configuration
/config/application.yml
Afterwards, I deploy the site. I open it up and data isn't going to the APIs anymore. OK...
cd into config and discover application.yml isn't there anymore. Paste it back in... Redeploy the site since now it understands it has to ignore that file and I'm not seeing changes on production. Check back... and its gone again!
Stumped on what's going on.
Simply putting a file into your deployed application's filesystem will not work because you get a clean environment each time you deploy. EngineYard cannot know that you want that particular file copied to that particular location without a little bit of extra work.
Their official recommendation is to put your YAML configuration files in /data/<app>/shared/config and symlink them to /data/<app>/current/config each time you deploy using deploy hooks.
I've always deployed my apps to ~/apps/myApp/current (with Capistrano, that's why I have the current directory).
But I've seen users deploy to like /var/www/, or even some make a directory at the root, /myapp.
I'm wondering is there an ideal place to put my app? Or does it not matter at all.
Additionally what do you usually name your user, I'm using deploy as my username and group, but I've seen users use rails or just whatever the username they always use is.
Is there a rule of thumb here? I'm aware that some may see this as a subjective question, I just wanted to get a little census as to what most people do.
On Ubuntu, /srv is a good place to install a rails app. Do not put it in /var/www, people would be able to browse your app sources in some circumstances.
The user www-data is perfect for running your app (when running apache, that's the default user). With Passenger, you can set PassengerDefaultUser www-data in its config file to enable that.
Do NOT run your app in as root. It's very dangerous.
/var/rails/app_name/current and deploy
I put all my web stuff under /var/www/ just because I like having it all in one place and /var/www/ is the default directory for Apache. There is no 'ideal' place to put your software - just put it wherever seems most logical to you. Pretty much the same for the username - I run my rails stuff under www-data but it doesn't matter what user you run it as (as long as it's not root).
Obviously clients shouldn't be allowed access to the rails app itself.
/srv is the right place to put your http or ftp , for more info visit https://help.ubuntu.com/community/LinuxFilesystemTreeOverview