Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Add Support for "Overwrite" instruction in appspec.yml "Files" section #14
Would like the ability to have an "overwrite" instruction in the appspec.yml "Files" section.
In my initial testing, I wanted to clobber all files in
I'd like to be able to create an appspec.yml file with the following section:
I've been working around by utilizing the hook section to do file copies. The hooks/shell script workaround is sufficient, rendering this a lower priority feature request.
Of course we need this feature!
Purge removes all files in the destination before performing copying the new files.
Merge leaves the destination as-is, adds the files from source and will replace an files in the destination that also exist in the source.
As for now I guess I need to stage my source files in a temp location and then run a script to achieve this.
+1 for this feature as well.
Side note: the Windows agent does NOT exhibit this behavior. I've been writing several appspecs for Windows services and I've never run into this. Only when we went to deploy to an Ubuntu server for the first time did we see this behavior.
5 similar comments
So, I hope this helps other people find a solution. In my situation I work a lot with Magento so I deal with PHP, nginx. Composer is also tossed in the mix. I found a solution that works for me and for my case. If anyone has any comments or suggestions, please let me know.
I wanted to be have the production directory synced with the repository that I was using so any file modifications would be reflected. Not just updates to files, but delete the files that are no longer required. I think this is what everyone really wants. The solution I found was to deploy the code into a temporary directory (
version: 0.0 os: linux files: - source: ./ destination: /var/www/release/ permissions: - object: /var/www/magento/ owner: www-data group: www-data hooks: BeforeInstall: - location: scripts/beforeInstall.bash AfterInstall: - location: scripts/afterInstall.bash
#!/usr/bin/env bash # I want to make sure that the directory is clean and has nothing left over from # previous deployments. The servers auto scale so the directory may or may not # exist. if [ -d /var/www/release ]; then rm -rf /var/www/release fi mkdir -vp /var/www/release
#!/usr/bin/env bash # I have left a few things in here and will explain this further (see below) rsync --delete-before --verbose --archive --exclude "htdocs/media/" --exclude ".*" --exclude "htdocs/var/" --exclude "htdocs/app/etc/local.xml" /var/www/release/ /var/www/magento/ > /var/log/deploy.log
There are also directories that are excluded from the rsync command. You do not need to sync cache directories and in my case the
All of the output is put into a deployment log (
Some things I want to try when I make the time, is to rsync files directly from the code-deploy directory. For each deployment, AWS CodeDeploy puts the code into a specific directory which you can reach by some of the environment variables it sets. This should speed up the deploy a little since it isn't putting the files in two places.
There are some things that have been left out of the scripts. Certain directories are
You can read more about the various hooks and when they occur in the docs at http://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html and also see the environment variables that can be used within the scripts.
2 similar comments
3 similar comments
... or they could just add support to overwrite files inside the appspec.yml as this issue is asking for and everything would work fine :)
I don't think it is quite as you say as " all following ones will use those settings.". They will not use whatever settings you used in the first deployment. The automatic deployment is set to (by default?) to not overwrite any existing file that it was not there already.
@thatianand - You will have to add overwrite flag while using aws createDeployment api.
Pasting this example from above -
Can this be implemented, please? I am trying to integrate an existing instance into a CodeDeploy workflow and it fails because - since it's a pre-existing server - the files are already there; They should just be overwritten. I really don't like that I have to create a extra script just for this one instance. Especially for "in palce" deployments it would make sense to have an overwrite option, either in the
@AntonChernysh yes, I could do that. But why can't I chose the overwrite option and have CodeDeploy overwrite the files if they exist? This project is not a simple "clear all" project; There are some folders on this instance which need to stay in-place and which are not in the appspec.yml, so I now have to manually delete them one by one.
When I use the AWS Console and create a new Deployment from "CodeBuild -> Deployments -> Create Deployment" I have these options for overwriting:
Which means CodeBuild is already capable of overwriting files - it just doesn't have an option via
@kevingimbel Obviously they don't want to implement this since this issue is open for a long time now.
You do it only once...
@AntonChernysh that's what I am doing now, but this is only possible when manually creating a deployment via CLI or AWS Console - and that's the problem.
IMO it should just be an option in the AppSpec or Deployment Group config.
Anyway, I think you're right regarding this not being implemented given that the issue has been open for 3 years.
Why is this not an option yet? Without appspec.yml option to specify overwrite behaviour, my auto-scaling groups cannot scale up because when Scale-Up event happens, the new instances do not CodeDeploy with overwrite behaviour!! This causes those launched instances to fail deployment ...
If the option was right there in the appspec.yml file - you know, since that file is supposed to dictate installation behaviour - we would be able to fully integrate code deploy with auto scaling but right now it fails ...