-
Notifications
You must be signed in to change notification settings - Fork 10
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
Custom Dockerfile could be a template #11
Comments
Thank you for your idea. I agree to use ERB template. For example, what do you think about like this?
driver:
image: marcy/hoge
dockerfile: dockerfile.erb
template_variables:
package: httpd
|
It sounds too specific (e.g. I always used the same one-liner dockerfile.erb (when I used kitchen-docker) in order to test the same image with Test Kitchen which I later template with Packer. Just But I like your idea from Readme:
or even more generic: instead of
But maybe that is, on the other hand, too generic? |
If we are using a custom Dockerfile(ERB), I think only the command written on the file should be used. Your example will be like this:
driver:
image: marcy/hoge
dockerfile: dockerfile.erb
template_variables:
run_commands:
- yum -y install httpd
environment:
- LANG: ja_JP.UTF-8
FROM <%= config[:image] %>
<% @run_commands.each do |c| %>
RUN <%= c %>
<% end %>
<% @environment.each do |k,v| %>
ENV <%= k %> <%= v %>
<% end %>
|
After some thinking I actually suggest no change in .kitchen.yml configuration. The only variable rendered in dockerfile.erb would be And there are 2 things here:
If you find it easier to implement the dockerfile.erb in this way (instead of 1st generating it from template and 2nd appending those lines), this will also work fine:
Thank you for so fast responses :) |
Oh, I'm sorry for the confusion. That means template variables should be distinguished from the other settings. There are no changes on other settings.
I agree with this. |
@marcy-terui are you working on this or prefer a pull request from me? |
+1 here. We are working with RedHat (they actually have official docker containers, but with no repo configured) and need to add our repo as the very first step. If you need any help or testing just tell me. |
I'll wait. |
done. |
This is released in v0.9.0 @xmik Please check the new version :) |
@marcy-terui, I tested on Ubuntu and Debian and it works :) thanks! |
Sorry, need to reopen. When I have the following dockerfile.erb:
And I run
from kitchen.log:
Edit: solution is to add this line:
as the first line of |
Now it works in both cases correctly: if I set env and cmds and if I not set them. Thank you for fast fix and release :) |
I'd like to use the same custom Dockerfile for several platforms. That implies using different docker base images, while the rest of the Dockerfile stays the same.
Solution
Custom Dockerfile could be rendered as a template (ERB). The following Dockerfile:
would be rendered to the
image
set in .kitchen.yml in driver_config section. Apart fromimage
, other variables could be rendered too (e.g.run_command
,environment
). That is already implemented in kitchen-docker.The text was updated successfully, but these errors were encountered: