nx-tools icon indicating copy to clipboard operation
nx-tools copied to clipboard

Incorrect outputPath in Dockerfile__template__ in case of SA project

Open alexIslander opened this issue 1 year ago • 0 comments

Hi All, I created a standalone angular project based on the official tutorial. Then i made a research how can i add docker support to the project via nx plugin and i found this tool.

I followed the documentation. The 'init' command generated the .Dockerfile as expected, however it was incorrect. All Dockerfile__template__ files has hardcoded as output folder 'dist/apps/...'. Since my project is SA setup i didn't have 'apps' subfolder in dist, only 'dist/my-projectname'.

When i removed the non existing subfolder from path everything worked fine.

Suggested fix

After i checked the generator code, i came up with the following ideas to fix the issue.

Fix A

Instead of hardcoding the outputPath in template files it could be read from project config, just as the projectName variable. 'target->build->options->outputPath'

Then here use COPY <%= projectOutputPath %>/package*.json ./ instead of COPY dist/apps/<%= projectName %>/package*.json ./

Fix B

Extend generator with an additional option, whether the project runs in mono repo or sa setup. Then use this info to populate 'apps' subfolder in the template files accordingly.

Affected files

All docker templates (under this folder) except empty template.

Please share you opinion on the issue. Thx.

alexIslander avatar Aug 09 '23 15:08 alexIslander