I created a simple todo list apache/php/mysql web app with 2 docker containers (one apache/php/code and one mysql). I then created an image on docker hub which embark the php code.
If someone wants to deploy my app, it has to :
I'm not sure it is best practise to distribute a public app this way. I would like to simplify the process. I think I could first remove the need to create a 000-default.conf file but I really don't know how where to start. Any thought or advise would be much appreciated. Thanks!
EDIT 1: following David comment :
The apache config file is very simple. It looks like this :
<VirtualHost *:80>
ServerName XXXXXX
DocumentRoot /var/www/html
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName XXXXXX
DocumentRoot /var/www/html
SSLCertificateFile /etc/apache2/ssl/fullchain.pem
SSLCertificateKeyFile /etc/apache2/ssl/privkey.pem
SSLEngine on
</VirtualHost>
</IfModule>
I see two problems:
I managed to include the apache config into the Docker image.
<VirtualHost *:80>
ServerName ${SERVER_NAME}
DocumentRoot /var/www/html
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName ${SERVER_NAME}
DocumentRoot /var/www/html
SSLCertificateFile ${SSL_CERT_FILE}
SSLCertificateKeyFile ${SSL_KEY_FILE}
SSLEngine on
</VirtualHost>
</IfModule>
COPY ./000-default.conf /etc/apache2/sites-available/000-default.conf
SERVER_NAME=mydomain.com
SSL_CERT_FILE=/etc/apache2/ssl/fullchain.pem # Uncomment if certificate provided into ssl folder
SSL_KEY_FILE=/etc/apache2/ssl/privkey.pem # Uncomment if certificate provided into ssl folder
to docker-compose.yml :
environment:
SERVER_NAME: ${SERVER_NAME}
SSL_CERT_FILE: ${SSL_CERT_FILE:-/etc/apache2/default_ssl/fullchain.pem}
SSL_KEY_FILE: ${SSL_KEY_FILE:-/etc/apache2/default_ssl/privkey.pem}
volumes:
- "./ssl:/etc/apache2/ssl"
The apache config in the container takes the values provided by the deployer in the .env. If he doesn't provide certificate, it takes the default auto-signed one included into the docker image.