Open JackGod001 opened 2 months ago
This PR addresses a potential issue with path duplication when generating Dockerfiles.
The change uses filepath.Base()
to extract just the filename from goFile
,
preventing situations where the project path might be inadvertently duplicated.
Changes made:
GoMainFrom
field assignment in the Docker struct to use filepath.Base(goFile)
.This change ensures that the path used in the Dockerfile is always relative to the project root, improving consistency and preventing potential build issues due to incorrect file paths.
Please merge the two submissions together, otherwise it will be incomplete
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 95.01%. Comparing base (
8690859
) to head (2153f14
). Report is 137 commits behind head on master.
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.