diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a37b360 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +**/.env.local \ No newline at end of file diff --git a/.env b/.env index 395865b..2418586 100644 --- a/.env +++ b/.env @@ -1,7 +1,23 @@ APP_ENV=prod DEFAULT_LOCALE=en +APP_SECRET=e80d9c53871bdaa0a1ff5357c695ba6d ###> symfony/lock ### # Choose one of the stores below # postgresql+advisory://db_user:db_password@localhost/db_name LOCK_DSN=semaphore ###< symfony/lock ### + +###> symfony/mailer ### +MAILER_DSN=smtp://{mail}:{password}@{host}:{port} +### ex with docker maildev : MAILER_DSN=smtp://localhost:25 +MAILER_SENDER=noreply@vision +###< symfony/mailer ### + +###> doctrine/doctrine-bundle ### +# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url +# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml +# +# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" +# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7&charset=utf8mb4" +DATABASE_URL="postgresql://symfony:ChangeMe@127.0.0.1:5432/app?serverVersion=13&charset=utf8" +###< doctrine/doctrine-bundle ### \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e3b0342..cfd1f45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,33 @@ -FROM php:8-apache +FROM php:8.1-apache -COPY . . -ENV DATABASE_URL=localhost - -# Apk install RUN apt update -y && apt install -y zip wget libbz2-dev libcurl4-openssl-dev zlib1g-dev libpng-dev libicu-dev libonig-dev libxslt-dev -# Install pdo -RUN docker-php-ext-install pdo_mysql bz2 curl fileinfo gd intl mbstring mysqli xsl -# Install composer -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php && php -r "unlink('composer-setup.php');" && mv composer.phar /usr/local/bin/composer -RUN composer install -n --no-scripts -RUN mkdir -p /var/www/html/var -RUN mkdir -p /var/www/html/var/log -RUN mkdir -p /var/www/html/var/cache -RUN chown -R www-data:www-data /var/www/html/var -ENV APACHE_DOCUMENT_ROOT /var/www/html/public +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ -RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf -RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf +RUN chmod +x /usr/local/bin/install-php-extensions && \ + install-php-extensions pdo_mysql bz2 curl fileinfo gd intl mbstring mysqli xsl -RUN chmod +x start.sh +RUN curl -sSk https://getcomposer.org/installer | php -- --disable-tls && \ + mv composer.phar /usr/local/bin/composer -WORKDIR /var/www/html -ENTRYPOINT ["./start.sh"] \ No newline at end of file + +COPY . /var/www/ + +COPY ./docker/apache.conf /etc/apache2/sites-available/000-default.conf + +RUN chown -R www-data:www-data /var/www + +USER www-data + +RUN cd /var/www && \ + composer install + +WORKDIR /var/www/ + +ENTRYPOINT ["bash", "./docker/docker.sh"] + +EXPOSE 80 \ No newline at end of file diff --git a/docker/apache.conf b/docker/apache.conf new file mode 100644 index 0000000..d0b98a3 --- /dev/null +++ b/docker/apache.conf @@ -0,0 +1,19 @@ + + ServerName localhost + + DocumentRoot /var/www/public + DirectoryIndex /index.php + + + AllowOverride None + Order Allow,Deny + Allow from All + + FallbackResource /index.php + + + + ErrorLog /var/log/apache2/project_error.log + CustomLog /var/log/apache2/project_access.log combined + + \ No newline at end of file diff --git a/docker/docker.sh b/docker/docker.sh new file mode 100644 index 0000000..1fc7e12 --- /dev/null +++ b/docker/docker.sh @@ -0,0 +1,3 @@ +php bin/console d:m:m --no-interaction +php bin/console cache:clear +exec apache2-foreground \ No newline at end of file diff --git a/start.sh b/start.sh deleted file mode 100644 index c9ac166..0000000 --- a/start.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -php bin/console doctrine:migrations:migrate --no-interaction -php bin/console cache:clear -a2enmod rewrite -chown www-data:www-data ./public/uploads -/usr/sbin/apachectl -D FOREGROUND \ No newline at end of file