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

Add More Config Options to Docker Contrib Module #1456

Merged
merged 4 commits into from
Sep 18, 2021

Conversation

LaurenceWarne
Copy link
Contributor

Hi! This PR adds some more options (pretty much correspond 1-1 with Dockerfile instructions) that can be used in DockerConfig. It's not totally comprehensive, but hopefully it catches the most common ones so there's less of a need to override DockerConfig.build.

I've added some tests which validate the new options by calling docker build - I could possibly replace these with tests against the generated Dockerfile strings if you think this is too much.

Thanks, I hope this is helpful.

Add exposedPorts, exposedUdpPorts, volumes, envVars and user as
overridable methods to DockerConfig trait.

object DockerModuleTest extends TestSuite {

object Docker extends TestUtil.BaseModule with JavaModule with DockerModule {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've written these based on the other contrib module test suites, let me know if there's anything untoward here.

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! Your changes look good to me. About the tests: I personally find the call to docker a rather hard requirement to pass the tests. Additionally nowadays, using podman is quite common, which is a daemon-less alternative to docker. As these test won't pass on Windows either, it's probably a good idea to add a test which only checks the expected Dockerfile correctness, and make the actual docker call test conditional, e.g. only when a docker (or podman) executable can be found.

@LaurenceWarne LaurenceWarne force-pushed the add-more-docker-config-options2 branch from 4d03bdf to ba5e846 Compare September 16, 2021 14:26
@LaurenceWarne
Copy link
Contributor Author

Thanks for taking a look! I've added tests against the dockerfile contents in ee6e601 and disabled the tests which invoke the docker executable in the case where it's not found.

docker (or podman)

Do you think we need to check for podman as well? https://podman.io/ recommends that you alias docker=podman, so the tests would still be ran in that case?

val testModuleSourcesPath: Path =
os.pwd / "contrib" / "docker" / "test" / "resources" / "docker"

private def isInstalled(executable: String): Boolean = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Do you think we need to check for podman as well? https://podman.io/ recommends that you alias docker=podman, so the tests would still be ran in that case?

The alias only works in a shell, so either we explicitly check and implement support for podman, or not. I leave it to you to decide. But if we support it, this is probably worth a dedicated target, which is then also user configurable (in case both tools are present).

os.makeDir.all(m.millSourcePath / os.up)
os.copy(testModuleSourcesPath, m.millSourcePath)
t(eval)
} else assert(true)
Copy link
Member

@lefou lefou Sep 16, 2021

Choose a reason for hiding this comment

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

I'd like to see a println() indicating that docker tests are skipped here.

Add tests for a docker config with defaults (no options) and
all options specified by building them (though only on
machines with docker installed).  Add tests which check the
contents of the generated dockerfiles as a fallback.
@LaurenceWarne LaurenceWarne force-pushed the add-more-docker-config-options2 branch from ba5e846 to 9af2def Compare September 17, 2021 08:46
@LaurenceWarne
Copy link
Contributor Author

LaurenceWarne commented Sep 17, 2021

I leave it to you to decide. But if we support it, this is probably worth a dedicated target, which is then also user configurable (in case both tools are present).

It's no problem, I've added a dedicated target in 9af2def. I've ran the tests against podman, docker and an environment without either, and everything looks ok 👍

@LaurenceWarne
Copy link
Contributor Author

I see a couple of the windows builds failed, currently 👀

@LaurenceWarne LaurenceWarne force-pushed the add-more-docker-config-options2 branch from 9af2def to 2b70bdf Compare September 17, 2021 11:39
@LaurenceWarne
Copy link
Contributor Author

image operating system "linux" cannot be used on this platform. I've disabled building for windows in the most recent commit, another solution could be to match on the platform to set the baseImage in the tests (though I'm not sure which image could be used 😄). What do you think?

@lefou
Copy link
Member

lefou commented Sep 17, 2021

Disabling docker live tests on Windows is perfectly fine, I think.

@LaurenceWarne LaurenceWarne force-pushed the add-more-docker-config-options2 branch from 2b70bdf to b7e35f7 Compare September 17, 2021 22:29
@LaurenceWarne LaurenceWarne force-pushed the add-more-docker-config-options2 branch from 048ee0f to 744c68d Compare September 18, 2021 15:00
@LaurenceWarne
Copy link
Contributor Author

Apologies, it's been a bit of a pain debugging some of the failures on the windows platforms, I think it should be good now though.

@lefou
Copy link
Member

lefou commented Sep 18, 2021

@LaurenceWarne Don't worry, it's the same for me. That's one of the reasons we have CI on Windows.

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you!

@lefou lefou merged commit 7f282a6 into com-lihaoyi:main Sep 18, 2021
@lefou lefou added this to the after 0.10.0-M2 milestone Sep 18, 2021
@LaurenceWarne
Copy link
Contributor Author

Thanks!

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.

2 participants