Ignoring folders and files on Codeship - deployment

I'm trying to figure out the best way to ignore some folders and files from my Codeship deployment process. At the moment it compiles all my assets as part of the deployment process but I don't really want it uploading node_modules to the server.
Is there a way to ignore the folder or remove the folder before deployment?
I tried deleting it after I ran grunt but I think it gets cached as it didn't work.

The method I used was to rm -r YOUR_PATH/node_modules in the test pipeline after Grunt has been run.
This however seemed to have some issues when running on FTP deploy. For any of the SSH deploys it seems to work fine.

Related

Ignore Files In Repo When Deploying To Netlify

I have a Github repo that includes some large graphical assets. These assets result in failed deploys to Netlify due to Netlify's size restrictions. Is there any way I can keep these files within the Github repo but exclude them from Netlify deploys, in the same way I could use a .slugignore file when deploying to heroku.
Netlify doesn't really have explicit size restrictions, though uploads of files >20MB may fail. Are your files bigger than that? If so, hosting them on Netlify's CDN also doesn't make sense as the CDN edge cache will ignore them and they'll load slowly for browsers anyway.
To not deploy them, the most straightforward way is to remove them after your build, something like this:
npm run build && rm dist/hugefile1.jpg dist/subdir/hugefile2.pdf
You can get fancier and use a file to list them or just look for everything huge. Warning - something huge that it DOES make sense to host is your sourcemap (if you use one), so watch out for what this might catch!
npm run build && find dist -type f -size +20M
Effectively - you can do anything you could do in a shell script. NB: You need to make sure that your build pipeline fails if any necessary step fails - this is why the examples show && to chain commands rather than ; (build could fail, find succeed, and we publish an empty site!).
More details here: https://www.netlify.com/blog/2016/10/18/how-our-build-bots-build-sites/ and you can test out your scripts using the methodology described here: https://github.com/netlify/build-image#testing-locally

How do I tell Codeship to ignore the node_modules folder?

I am deploying to AWS EB from Codeship. Codeship does an npm install to run the tests. It them bundles everything and sends it to AWS, where another npm install happens.
How do I prevent Codeship from bundling my node_modules folder?
The integrated Elastic Beanstalk deployment is based on copying the files over to AWS, so if you want to "ignore" a folder, add a script based deployment before the Elastic Beanstalk deployment and remove the folders you don't want to copy over.
See https://github.com/codeship/scripts/blob/master/deployments/elastic_beanstalk.sh for a script that is very similar (though not quite identical) to the commands run for the integrated deployment.
And see https://documentation.codeship.com/basic/builds-and-configuration/deployment-pipelines/#multi-step-deployment-pipelines for a bit more information on deployment pipelines containing multiple individual steps.

Deploy build files from continuous integration

I am working on a project with multiple people, a website application which requires webpack to be built, uglified, concatenated into a few files e.g. app.min.js, style.min.css etc. - As a result of this, in an effort to prevent merge conflicts we recently added the build folder to .gitignore, under the assumption that we would be able to build during deployment.
When pushing to the Master branch, we automatically "deploy" through Semaphore CI (similar to Travis) which runs composer install, npm install, and finally "npm run build" which triggers the webpack build. This is all built and then tested on the CI side of things, and then Semaphore automatically deploys to Amazon's Elastic Beanstalk where our application is hosted.
The problem with this is, it seems Semaphore doesn't upload the build it's just tested, but rather the Master branch itself which has no built JS or CSS. I'm wondering if there's a way to push these built files to deployment as well, or if running the entire build process AGAIN on Elastic Beanstalk is the only route. It seems unnecessary to have to do that process essentially 3 times, locally, CI, and then deployment. Every time a step like this is needed on EB the actual re-instantiation time gets longer, which I'd like to keep as short as possible.
Obviously if building it a 3rd time on EB is the only way to go about this then I'll have to, just wondering if there are better solutions for this whole workflow.
I haven't worked with Semaphore CI, but you might be able to use an .ebignore file.
If you create one, the cli will use that instead of your .gitignore file.
I find in some deployment situations you want the inverse of your .gitignore (all compiled, no src). It essentially lets you pick the files from your project directory that you want to deploy, in the same way as the .gitignore file.
Edit: I just noticed the documentation on aws is lacking. It only mentions file exclusion, but you can include files too.
Edit 2: I don't think Semaphore supports the use of .ebignore, so right now this solution isn't of any use. :(
I just had a great first experience with https://deploybot.com/. The can deploy directly to elastic beanstalk. It might be interesting or you.

How do I speed up an EB deploy using ebignore?

I'm deploying my app to ElasticBeanstalk. I'm using an .ebignore file because there are files that I do not want to check into git, but I do want deployed with the app(like application secrets, config vars, etc). The issue I'm facing is that when using an .ebignore, the deploy takes FOREVER. I've used the --verbose flag, and I can see that it is recursing my entire node_modules directory and skipping each file individually. When I deploy by using .gitignore, it becomes very fast.
Has anyone else experienced this? How do I speed up this process?

How to deploy local files without commiting to git?

I'm working in local branch and want to try my changes on staging server, but I don't want to commit these changes. Can I commit local changes.
I know about deploy:upload recipe. I need a way to deploy several files or whole working derictory.
Thanks.
Most important of capistrano is to allow execute code on remote server, what we call deploy is a set of default scripts that do a lot of small tasks required for setting up new version of application on server.
So it is possible to write your own scrip that will execute following script (it's not working probably):
pack sources
system "tar -czf /tmp/package.tgz *"
upload it to server
upload "/tmp/package.tgz" "/tmp/package.tgz"
remove old files, unpack sources on server
run "cd /app_path/; rm -rf *; tar -xzf /tmp/package.tgz"
override (force recursively symlinks) files with some server configs ... like database.yml
run "cp -flrs /app_shared_path/* /app_path/"
restart application - this is for passenger, use your own server command for restart
run "cd /app_path/; touch tmp/restart.txt"
I did similar setup once for deployment - before I got access to git.
I deploy some cached (minified, etc) javascript files from a rails app. The simplest way is just to do this in a capestrano task:
top.upload("public/javascripts/cache", "#{current_path}/public/javascripts/cache")
This will use scp to upload the entire 'cache' directory.