Writing dockerfile
suggest changeDockerfile is used to configure the custom image that we will be building with the web-application codes. Create a new file Dockerfile in the root folder of project and then put the following contents in the same
FROM php:7.0-apache
COPY /etc/php/php.ini /usr/local/etc/php/
COPY . /var/www/html/
EXPOSE 80
The first line is straightforward and describes which image should be used to build our new image. The same could be changed to any other specific version of PHP from the registry.
The second line copies a php.ini file into the image. The source path is relative to the build context, not an absolute path on the host. You can change that file to some other custom file location.
The third line would copy the code in the current directory to /var/www/html, which is the webroot inside the image.
The last line documents port 80. EXPOSE does not publish that port on the host.
Ignoring files
In some instances there might be some files that you don’t want on server like environment configuration etc. Let us assume that we have our environment in .env. Now in order to ignore this file, we can simply add it to .dockerignore in the root folder of our codebase.