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

The second FROM stage should be named #1315

Closed
jroper opened this issue Mar 12, 2020 · 2 comments · Fixed by #1316
Closed

The second FROM stage should be named #1315

jroper opened this issue Mar 12, 2020 · 2 comments · Fixed by #1316

Comments

@jroper
Copy link
Member

jroper commented Mar 12, 2020

Currently, only the first stage of the Docker build is named, ie, as stage0. The second should also be named. Why? Because this allows additional stages to be easily appended to the build, that may be based on completely different images based on those stages build requirements, and then you go back to native packagers stage and copy artifacts from the additional stages. Otherwise, you need to somehow inject those stages somewhere in the middle of the build which is not at all easy to do. I would suggest that this final stage be given a well known name that never changes, eg main.

@jroper
Copy link
Member Author

jroper commented Mar 12, 2020

Here's an example config, here I create another stage based on alpine/git so that I can clone some content from a github repo, and then I copy it into my image:

dockerCommands := dockerCommands.value.map {
  case Cmd("FROM", unnamed) => Cmd("FROM", unnamed, "as", "main")
  case other => other
} ++ Seq(
  Cmd("FROM", "alpine/git", "as", "git"),
  Cmd("WORKDIR", "/opt/docker"),
  Cmd("RUN", "git", "clone", "https://github.com/jroper/jazzyidau.git", "blogs", "--no-checkout"),
  Cmd("FROM", "main"),
  Cmd("COPY", "--from=git", "--chown=1001", "/opt/docker/blogs", "/var/blogs"),
  Cmd("ENV", "GIT_REPO", "/var/blogs"),
)

As you can see, I've worked around this issue by renaming the second stage to main.

@muuki88
Copy link
Contributor

muuki88 commented Mar 16, 2020

Thanks for the feature request @jroper 🤗 . Sounds reasonable to me 😄 Would you like to open a pull request for this?

jroper added a commit to jroper/sbt-native-packager that referenced this issue Mar 16, 2020
muuki88 pushed a commit that referenced this issue Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants