This one is for mainly my own reference that is why it isn't listed on the main README.md in this repository.
For this project, I used the [symfony](https://github.com/kasteckis/symfony-docker-compose) docker container to host a php application, [vCard to LDIF/CSV Converter](https://github.com/thomascube/vcfconvert) by u/thomascube.
Symfony can help you host any php application. For this example, I selfhost vcfconvert.
### Minimum File Structure
```
/home/
└── ~/
└── docker/
└── vcfconvert/
├── .docker <--Thisisadirectory
├── Dockerfile
├── virtualhost.conf
├── docker-compose.yml
├── <PHPAPPLICATIONFILES>
```
### Add to Caddyfile (from ~/docker/caddy)
Remember to `docker exec -w /etc/caddy caddy caddy reload` after editing your Caddyfile.
The only thing you need to change in this file is the second line `RUN echo "ServerName vcfconvert.yourdomain.com" >> /etc/apache2/apache2.conf` use your own domain here.
```
# Use image which contains apache with php
FROM php:7.4.13-apache
RUN echo "ServerName vcfconvert.yourdomain.com" >> /etc/apache2/apache2.conf
RUN apt-get update && apt-get upgrade -y
# Install packages needed to install php extensions
RUN apt-get install git zlib1g-dev libxml2-dev libzip-dev zip unzip -y
# Install PHP extensions
RUN docker-php-ext-install zip intl mysqli pdo pdo_mysql opcache
# Install NPM
RUN apt-get install npm -y
# Upgrade npm to latest version
RUN npm install -g npm
# Install node manager - n
RUN npm install -g n
# Install latest stable node version
RUN n stable
# Install sass compiler
RUN npm install -g sass
# Install XDEBUG
RUN pecl install xdebug-2.9.8 && docker-php-ext-enable xdebug
RUN echo 'xdebug.remote_port=9000' >> /usr/local/etc/php/php.ini
RUN echo 'xdebug.remote_enable=1' >> /usr/local/etc/php/php.ini
RUN echo 'xdebug.remote_connect_back=1' >> /usr/local/etc/php/php.ini
# Install composer command
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
# Install symfony command
RUN curl -sS https://get.symfony.com/cli/installer | bash && mv /root/.symfony/bin/symfony /usr/local/bin/symfony
# Set umask to 0000 (newly created files will have 777 permissions)
RUN echo "umask 0000" >> /root/.bashrc
```
### .docker/virtualhost.conf
Again change the second line to your own domain. `ServerName vcfconvert.yourdomain.com`
```
<VirtualHost*:80>
ServerName vcfconvert.yourdomain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
DirectoryIndex /index.php
<Directory/var/www/html/public>
AllowOverride None
Order Allow,Deny
Allow from All
FallbackResource /index.php
</Directory>
<Directory/var/www/html/public/bundles>
FallbackResource disabled
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```
### docker-compose.yml
Here you want to focus on the `web:` section.
Here I added the caddy network which is similar to all my previous self-hosted docker apps. This is so I can have caddy reverse proxy into the php app's container.
For the volumes. I wrote in the path of the directory that contains the `index.php` file and point it to `/var/www/html/` in the container.