'Nginx chef docker

I am new to docker concept. For an application I need to create nginx container. The nginx configuration is in chef cookbook, hence I have example.conf.erb file and default.rb (containing setup nginx file) in my chef/cookbook/ directory . I am not sure how to containerise. I copied .conf.erb to /etc/nginx/conf.d/example.conf.erb. I am not sure what else to do. I am confused and no resource online need help immediate default.rb :

   include_recipe 'nginx_ldap_auth'
   include_recipe 'nginx'
   template 'nginx config' do
   source 'example.conf.erb'
   path '/etc/nginx/conf.d/example.conf.erb'

   owner 'root'
   group 'root'
   mode ''
   variables({'environment variables'})
   notifies :restart, 'service[nginx])'

My Dockerfile currently look like this:

FROM nginx:alpine

COPY default.conf /etc/nginx/example.conf.erb/

I am not sure if I need docker-compose. Apart from Dockerfile there is nothing much I have created. Please guide



Solution 1:[1]

Either first let Chef create the config file and then run run docker build to create an image.

Or you can check out a multi stage dockerfiles.

With multiple stages you can first use an image that includes Chef, there create the config file and then copy it into the nginx image.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ino