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

prepend dockerCommands #1437

Closed
wants to merge 8 commits into from
Closed

prepend dockerCommands #1437

wants to merge 8 commits into from

Conversation

frankivo
Copy link
Contributor

Trying to fix #1417. Not sure if this is they way, feel free to comment :)

@lightbend-cla-validator

At least one pull request committer is not linked to a user. See https://help.github.com/en/articles/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user

@frankivo
Copy link
Contributor Author

frankivo commented Jul 15, 2021

Usage in build.sbt:
dockerCommandsPrepend := Seq(Cmd("RUN", "apk add --no-cache ttf-dejavu bash"))

@lightbend-cla-validator

At least one pull request committer is not linked to a user. See https://help.github.com/en/articles/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user

@muuki88
Copy link
Contributor

muuki88 commented Jul 21, 2021

Not sure if a separate tasks is the way to go here. Prepending (not inserting into an arbitrary position) should be doable with

dockerCommands := List("foo", "bar") ++ dockerCommands.value

Maybe this is something for the documentation?

@frankivo
Copy link
Contributor Author

Not sure if a separate tasks is the way to go here. Prepending (not inserting into an arbitrary position) should be doable with

dockerCommands := List("foo", "bar") ++ dockerCommands.value

Maybe this is something for the documentation?

That will break the build as the commands will be before "FROM".
I do agree that the insert position is somewhat arbitrary.

@lightbend-cla-validator

At least one pull request committer is not linked to a user. See https://help.github.com/en/articles/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user

@lightbend-cla-validator

At least one pull request committer is not linked to a user. See https://help.github.com/en/articles/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user

@muuki88
Copy link
Contributor

muuki88 commented Feb 21, 2022

Thanks @frankivo for keeping this PR up-to-date.

I'm still unsure that this setting is a good idea. It may cause more confusion that help and creates a precedence for settings that insert docker commands in arbitrary positions.

The main issue from what I understand is finding the right spot to insert aditional docker commands. What do you think of

  • adding Comment lines to the docker file with fixed names
  • provide helpers to insert at this fixed "marks"

For example

FROM openjdk:8 as stage0
# stage0:after:from
WORKDIR /opt/docker
COPY opt /opt
USER root
RUN ["chmod", "-R", "u=rX,g=rX", "/opt/docker"]

FROM openjdk:8
# image:after:from
RUN id -u daemon || useradd --system --create-home --uid 1001 --gid 0 daemon
WORKDIR /opt/docker
# image:after:workdir
COPY --from=stage0 --chown=daemon:root /opt/docker /opt/docker
USER 1001
ENTRYPOINT []
CMD []

and the

dockerCommands := prependDockerCommandAfter(dockerCommands.value, Docker.ImageWorkdir, List(...))

this is not super elegant. But you get the idea. This is a more extendible approach. If you have a better API, feel free 😄

@frankivo
Copy link
Contributor Author

@muuki88 I like that idea actually. Don't have much time this week, but I'll see if I can update this PR with your suggestion.

@lightbend-cla-validator
Copy link

At least one pull request committer is not linked to a user. See https://help.github.com/en/articles/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user

@frankivo
Copy link
Contributor Author

frankivo commented Mar 3, 2022

I implemented your suggestions @muuki88. We could add more, but first let me know what you think.

Example usage: frankivo/covid-telegram@89b1a03

@muuki88
Copy link
Contributor

muuki88 commented Mar 4, 2022

Thanks a lot. I'll take a look ASAP. 🤗❤️

@muuki88
Copy link
Contributor

muuki88 commented Mar 30, 2022

I have not forgotten this pull request 😘😘

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

additions to dockerCommands are run as user
3 participants