fix: ensure Dockerfile includes etc directory and correct CMD based on config #4343
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix: ensure Dockerfile includes etc directory and correct CMD based on config
Bug Fix: Include etc directory in Dockerfile and set correct CMD based on config
Description
This PR fixes two related issues:
goctl docker
from a directory different from where the Go file is located.Problems
goctl docker
from a directory that was not the same as the Go file's location, the generated Dockerfile did not include the etc directory. This caused issues for projects that rely on configuration files stored in the etc directory.Solution
The fix involves modifying the
dockerCommand
function to:Changes made:
filepath.Join
for better cross-platform compatibility.Testing
Tested the changes by:
goctl docker
from various directory locations relative to the Go file, confirming that the etc directory is correctly included in all cases where it exists.Additional Notes
This fix improves the reliability and consistency of the
goctl docker
command, especially for users working with more complex project structures or running the command from different locations within their project. It ensures that not only is the etc directory properly included, but also that the resulting Docker containers are configured correctly based on the project's configuration files.