-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include .git
directory in the Docker image
#569
Conversation
We need to have .git directory in the deployed project so that we can get and show the commit hash of the deployed project.
This is incorrect AFAIK. @borela how do you get the commit better in docker builds? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see prior comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use ARGs and pass the commit to the build command.
But we use I am thinking of a rake task for this. It can return the value from either an env variable like This way, the code works fine regardless of being in docker or not. Note:
|
@ahangarha we need to update the tool to be able to pass args to the docker image too, people might need it for other purposes. |
@borela Got it. |
See #117 |
Why? why should the .git directory be included in a .dockerignore Reduce Image Size: .git directories often contain a lot of metadata and historical data that are not necessary for running the application. Excluding this directory can significantly reduce the size of the Docker image. Security: The .git directory may contain sensitive information, such as commit history, configuration details, or even credentials in some cases. Excluding it from the Docker image helps to prevent unintended exposure of this information. Build Efficiency: Docker builds can be faster when the context sent to the Docker daemon is smaller. The .git directory can be quite large, especially for long-standing projects, so excluding it can speed up the build process. Clean Environment: Docker images are intended to be minimal and specific to the application's runtime requirements. Including only what is necessary for the application to run ensures a clean, minimal environment, which is a best practice for Docker usage. Avoid Unnecessary Rebuilds: Docker uses the context sent to the daemon to determine if an image needs to be rebuilt. Changes in the .git directory that are irrelevant to the application's functionality could trigger unnecessary rebuilds, thus excluding it can help in avoiding this. Compliance and Best Practices: For compliance with various security and operational best practices, it's essential to keep Docker images lean and free from unnecessary files. This aids in maintaining a standardized and secure deployment process. In summary, excluding the .git directory from Docker builds results in smaller, more secure, and efficient images, aligning with best practices for Docker usage. |
We need to have the
.git
directory in the deployed project to get and show the commit hash of the deployed project.This change is