advapi
advapi

Reputation: 3907

Where to put httpd.conf in the repository to create a docker image

I need to build a docker image based on httpd:2.4 and I've to apply some customization I've defined inside my own httpd.conf. Now my question is where to put this file in my git repo so it's correctly injected in the docker image.

Consider I've got the dockerfile inside my project folder and at the same level I've got the .dockerignore.

What is the best practice to put such a file, that's not strictly related to the project (I mean, I can also deploy this as a standard application without dockerizing)? Should it be placed in an upper folder? called how?

Thanks in advance

Upvotes: 0

Views: 246

Answers (1)

rolf82
rolf82

Reputation: 1581

On the page of the image on dockerhub you have an example how to customize the configuration:

FROM httpd:2.4
COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf

There's no magic, you tell docker which file to take from your context and where it should be put.So you can basically put the file anywhere. For example you could have this simple structure:

Dockerfile
app/
  your app files if any
conf/
  my-httpd.conf

So you'd have this in you Dockerfile:

COPY conf/my-httpd.conf /usr/local/apache2/conf/httpd.conf

The structure of your repo is free. You could even have your dockerfile or dockerfiles in a separate folder and a folder for your build context as explained in the best practices.

Anyway there are as always many ways to do but I think you should keep it as simple as possible according to your use case.

Upvotes: 1

Related Questions