From 3cdea8acaebb5a262bb22443c89b4754740749e1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 10 Aug 2022 13:24:35 +0200 Subject: [PATCH] read me and some ssl stuff --- Dockerfile | 15 ++++++++++----- README.md | 15 +++++++++++++++ docker-compose.yml | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index e5ab314..f710de0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,10 +37,10 @@ RUN chmod +x /install_composer.sh \ && rm /install_composer.sh \ && mv /composer.phar /usr/local/bin/composer -#RUN a2enmod rewrite && a2enmod ssl && a2enmod socache_shmcb -RUN a2enmod rewrite && a2enmod ssl -COPY ./.docker/apache/httpd.conf /etc/apache2/sites-available/httpd.conf -COPY ./.docker/apache/httpd.conf /etc/apache2/conf-available/httpd.conf +RUN a2enmod rewrite && a2enmod ssl && a2enmod socache_shmcb +#RUN a2enmod rewrite && a2enmod ssl +#COPY ./.docker/apache/httpd.conf /etc/apache2/sites-available/httpd.conf +#COPY ./.docker/apache/httpd.conf /etc/apache2/conf-available/httpd.conf COPY ./cert/mycert.crt /etc/ssl/certs/mycert.crt COPY ./cert/mycert.key /etc/ssl/private/mycert.key @@ -54,7 +54,12 @@ RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf #RUN sed -i '/SSLCertificateFile.*snakeoil\.pem/c\SSLCertificateFile \/etc\/ssl\/certs\/mycert.crt' /etc/apache2/sites-enabled/*.conf #RUN sed -i '/SSLCertificateKeyFile.*snakeoil\.key/cSSLCertificateKeyFile /etc/ssl/private/mycert.key\' /etc/apache2/sites-enabled/*.conf -RUN a2ensite httpd +RUN sed -i '/SSLCertificateFile.*snakeoil\.pem/c\SSLCertificateFile /etc/ssl/certs/mycert.crt' /etc/apache2/sites-available/default-ssl.conf +RUN sed -i '/SSLCertificateKeyFile.*snakeoil\.key/cSSLCertificateKeyFile /etc/ssl/private/mycert.key\' /etc/apache2/sites-available/default-ssl.conf + +RUN a2ensite default-ssl +RUN apt-get update && apt-get upgrade -y +#RUN a2ensite httpd RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" diff --git a/README.md b/README.md index f22c9fd..3363f68 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ # contao-docker-test #Installation: +- Create a new folder "cert" in project root, enter it in terminal and create SSL-certificate files: + - `openssl req -x509 -new -out mycert.crt -keyout mycert.key -days 365 -newkey rsa:4096 -sha256 -nodes` + - Enter a name for your local domain name e.g. "local-docker" as "Common Name", all other information are not relevant + and you can skip them with enter + - Make sure your local domain name is entered in the host file + (Unix, Mac: /etc/hosts | Windows: C:\Windows\System32\drivers\etc\hosts) like this: + "127.0.0.1 localhost local-docker" + - Later when the app is ready you can use this domain name to call with the browser + - A full guide is here: + [SSL Docker Installation](https://forums.docker.com/t/setup-local-domain-and-ssl-for-php-apache-container/116015) - Start docker app (e.g. Docker Desktop) - Go to root folder in terminal and create docker containers: `docker-compose up -d` - Create a database for contao in database container: @@ -78,6 +88,11 @@ - `docker rmi $(docker images -q)` - `docker stop contao && docker rm contao && docker rmi php-apache-contao && docker-compose up -d` +# Some helpful other commands: +- Restart Apache within the container + - Go into docker container `docker exec -it contao /bin/bash` + - Apache restart `sudo /etc/init.d/apache2 reload` + # Clean restart of Docker instance 1. Stop the container(s) using the following command: `docker-compose down` 2. Delete all containers using the following command: `docker rm -f $(docker ps -a -q)` diff --git a/docker-compose.yml b/docker-compose.yml index e7646e6..ba5c968 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,7 @@ services: build: context: ./ dockerfile: Dockerfile - image: 'php-apache-contao' + image: 'spt-contao' container_name: contao ports: - '8089:80'