Search code examples
amazon-web-servicessmartyamazon-elastic-beanstalkaws-codepipelineaws-codecommit

Smarty files are not recompiled using Elastic Beanstalk, CodePipeline and CodeCommit


I am using Elastic Beanstalk, deploying my application using CodeCommit and CodePipeline. I am using Smarty for templating. To avoid recompilation of all templates whenever I deploy a new version of my application, I would like to keep the compiled template files outside of the /var/app/current/ directory, where they would be removed with each deployment.

But when I do this, Smarty does not update the compiled template files when the original template files are updated. I have investigated to find out the cause, and when I look at my original template files on the EC2 instances, they all have a last modified date of 1979-12-31 05:08:00.

It seems that Elastic Beanstalk does not preserve the modification date of the files when deploying. Maybe the original modification dates are lost in CodeCommit or CodePipeline?

My guess is that Smarty looks at the modification date of the files to determine whether the compiled files are up to date or not. And since the compiled templates are newer than the original templates, they are considered up to date even when they are not.

Any ideas to how I can solve this problem, except for deleting the compiled templates with every new deployment? Is there a way to make Elastic Beanstalk preserve the modification times? Or is there a way to make Smarty understand that a template file has been updated besides the file's modification date?


Solution

  • CodeCommit generates a zip archive for the latest commit in your repository to S3. CodePipeline uses this archive for your ElasticBeanstalk application.

    The modified date of each file in the zip archive is set to 0 epoch or January 1, 1970 12:00:00 AM GMT, regardless of when the file was last added or changed in the repository. In the future, this might be changed to the timestamp that the archive was generated or the timestamp that the commit was made.

    So, we do not advise depending on the last modified date of the files to make any decisions on your application logic. It is unclear to me why the last modified date that you see is 1979-12-31 05:08:00 (10 years after 0 epoch).