Skip to content
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

feat: add option to override image entrypoint and command #131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

d-costa
Copy link
Collaborator

@d-costa d-costa commented Nov 27, 2023

what

  • Give users the option to override container image entrypoint and command.

why

  • Sometimes there is a need to modify the container's startup behavior, without directly modifying the image.
  • More specifically, this feature can be used to inject a script before the Atlantis entrypoint to perform an initial setup, for example, to install gcloud, fetch secrets from Secret Manager (or other locations), and export environment variables.
  • This allows users to export environment variables that do not appear in the Console (e.g. ATLANTIS_GH_WEBHOOK_SECRET)

Our use case

In the instance startup script, we create a custom entrypoint script, and place it in atlantis' home folder through the existing mountpoint. This custom entrypoint performs an initial setup (as described above), and calls the original atlantis entrypoint.

references

notes

May be relevant to add this info to the readme?

If CMD is defined from the base image, setting ENTRYPOINT will reset CMD to an empty value.
https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact

@bschaatsbergen
Copy link
Contributor

This is awesome @d-costa, could you please add your suggestion to the readme and perhaps add an example in the secure env vars directory?

@d-costa
Copy link
Collaborator Author

d-costa commented Dec 4, 2023

Hey @bschaatsbergen, I added an example, let me know what you think!

PS: I had to throw in a chown 100 /mnt/disks/gce-containers-mounts/gce-persistent-disks/atlantis-disk-0/ in the script, because the folder's owner was never being changed from root when using this startup script. Do you have any idea of why that might happen?

@d-costa d-costa force-pushed the entrypoint branch 3 times, most recently from b8a4081 to 39bd03e Compare December 4, 2023 12:28
@bschaatsbergen
Copy link
Contributor

Awesome, I'm reviewing this tonight :)

@bschaatsbergen
Copy link
Contributor

bschaatsbergen commented Dec 4, 2023

Hey @bschaatsbergen, I added an example, let me know what you think!

PS: I had to throw in a chown 100 /mnt/disks/gce-containers-mounts/gce-persistent-disks/atlantis-disk-0/ in the script, because the folder's owner was never being changed from root when using this startup script. Do you have any idea of why that might happen?

We do the same actually in the cloud init! It might be that it's done double now and that the startup script is excuted before the cloudinit

@bschaatsbergen
Copy link
Contributor

The changes seem good to me, though I think we should have the example under the "secure-env-vars" directory, as this is primarily used to secure the environment variables and not have them leak in the Google Cloud UI. Is this something you could do please? 🙏🏼 @d-costa

Then I would like to merge this PR.

@bschaatsbergen bschaatsbergen added documentation Improvements or additions to documentation major Breaking changes (or first stable release) labels Dec 4, 2023
@bschaatsbergen
Copy link
Contributor

Note for self: needs to be released under a major as this is a breaking change.

@d-costa d-costa force-pushed the entrypoint branch 2 times, most recently from 3ef3715 to 55fe565 Compare December 5, 2023 16:35
@bschaatsbergen
Copy link
Contributor

bschaatsbergen commented Dec 6, 2023

You're doing some really awesome work @d-costa - excuse me for my slow review cycle.

@bschaatsbergen
Copy link
Contributor

bschaatsbergen commented Dec 8, 2023

Please rebase @d-costa

Copy link
Contributor

@bschaatsbergen bschaatsbergen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got 1 question around possibly improving the script. I'm very happy with this PR 👍🏼

examples/secure-env-vars/custom-entrypoint.sh.tftpl Outdated Show resolved Hide resolved
examples/secure-env-vars/server-atlantis.yaml Outdated Show resolved Hide resolved
@bschaatsbergen
Copy link
Contributor

Can you rebase this branch one more time @d-costa ?

@dgteixeira
Copy link

hey @bschaatsbergen , how are you?
Any idea on when you might be able to review this and #139

We are currently using a local version of this but we would love to point all the way to your upstream :)

@bschaatsbergen
Copy link
Contributor

hey @bschaatsbergen , how are you? Any idea on when you might be able to review this and #139

We are currently using a local version of this but we would love to point all the way to your upstream :)

Hi @dgteixeira, thanks for getting in touch. Now that the repository has been transferred to the runatlantis organization, and you, @d-costa, @DanielRieske, and @cblkwell are maintainers of this repository, I encourage you to collaborate on addressing these PRs together :)

@cblkwell
Copy link
Contributor

cblkwell commented Apr 1, 2024

This also looks fine -- since this and the other PR are fairly sizable changes, it is probably best to get them both merged in and then cut the new major version. We should resolve conflicts before we move forward though.

@d-costa d-costa requested a review from a team as a code owner April 1, 2024 15:29
@d-costa d-costa self-assigned this Apr 7, 2024
@d-costa
Copy link
Collaborator Author

d-costa commented Apr 19, 2024

This is a breaking change:

module.atlantis.google_compute_instance_template.default must be replaced

Due to the changes in the gce-container-declaration metadata field:

    +     "args": null
    +     "command": null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation major Breaking changes (or first stable release)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants