louislam / dockge

A fancy, easy-to-use and reactive self-hosted docker compose.yaml stack-oriented manager
https://dockge.kuma.pet
MIT License
11.95k stars 336 forks source link

Commented out lines in compose file disappear when starting/deploying container. #176

Open JohnDoe-dev-spec opened 9 months ago

JohnDoe-dev-spec commented 9 months ago

⚠️ Please verify that this bug has NOT been reported before.

πŸ›‘οΈ Security Policy

Description

I have created a new stack with Dockge and commented out some lines in the YAML with #

I then start/deploy the stack and it creates successfully and refreshed the page. The compose.yaml no longer shows me the commented out line, it disappears.

I then login to the host and nano compose.yaml and i can see the commented out line there but not in Dockge.

πŸ‘Ÿ Reproduction steps

Create stack and comment out line Deploy/start stack Refresh Page

Line disappears

πŸ‘€ Expected behavior

The commented out line still to appear in my compose.yaml so i can reintroduce it if i want to.

πŸ˜“ Actual Behavior

Commented out line disappears from Dockge GUI

Dockge Version

1.1.1.1

πŸ’» Operating System and Arch

DietPI Debian

🌐 Browser

Firefox/Chrome

πŸ‹ Docker Version

Docker 24.0.7

🟩 NodeJS Version

N/A

πŸ“ Relevant log output

No response

cirrusflyer commented 9 months ago

Noticed this too.

louislam commented 9 months ago

Need an example, I cannot reproduce. Still there after refresh.

image

JohnDoe-dev-spec commented 9 months ago

I can't seem to reproduce it either anymore.

It did disappear!

Close this off for now and if it happens again i will re-open with example.

Thanks!

marvint24 commented 6 months ago

It's seams like that this is still an issue. Steps to reproduce:

andzno1 commented 6 months ago

I can confirm that it's still happening. The lines disappear as soon as you start editing the stack.

Edit to say that only certain comments will disappear, as the one provided in this comment. Commenting out the whole ports entry will not be affected.

mikansontap123 commented 3 months ago

@louislam Can we re-open this issue please? The steps given by @marvint24 also are reproduceable on my end.

bpbradley commented 2 months ago

Happens reliably when commenting out a label.

Robonau commented 1 month ago

was looking in to this because its really annoying. it happens on this parseDocument function call https://github.com/louislam/dockge/blob/109222f0248e17935db439d2db0eb421194007da/frontend/src/pages/Compose.vue#L703

it can deal with comments at the start and end of an array but not in the middle so

label:
  # comment at start of object
  - label.on.container=true
  # comment at middle of object
  - label.on.container2=false
  # comment at end of object

would remove the middle comment but the start and end ones would stay leading to the front-end displaying

label:
  # comment at start of object
  - label.on.container=true
  - label.on.container2=false
  # comment at end of object

to be clear the comment is actually there in the file until you save/deploy it again after editing its just failing at the yaml > object step to making it editable in the browser

Robonau commented 1 month ago

a work around for now is to do like so

labels:
  # comment at start of object
  - label.on.container=true
  - a # comment at middle of object
  - label.on.container2=false
  - b # comment at middle2 of object
  - c # comment at middle3 of object
  - d # comment at middle4 of object
  - label.on.container3=false
  # comment at end of object

this should work fine for both labels and environment as the a,b,c,d values are just ignored if they are not used

shalafi99 commented 1 week ago

I can confirm the workaround @Robonau suggested, lines which are only a comment get removed when you edit the compose. except if they are placed right below a section start or right at its end.

And comments placed to the right of a compose parameter are left untouched.

Also, upon editing the template the comments which do not get removed have their indentation changed like so (probably by design, but as they being comments I did not expect it to happen):

An saved example compose excerpt:

volumes: # to the right of section name # at beginning of section - ./data:/data # at end of section

When I edit it:

volumes: # to the right of section name (moved down and got indented to align with the existing parameter) # at beginning of section (indented to align with the existing parameter ) - ./data:/data # at end of section (indented to align with the section title)