Merge branch 'Xbird/WorkOnDocker' into 'main'

Rework docker approach

See merge request gamexperience/vision!16
This commit is contained in:
Xbird
2022-03-30 19:42:39 +00:00
6 changed files with 62 additions and 26 deletions

1
.dockerignore Normal file
View File

@@ -0,0 +1 @@
**/.env.local

16
.env
View File

@@ -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 ###

View File

@@ -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"]
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

19
docker/apache.conf Normal file
View File

@@ -0,0 +1,19 @@
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/public
DirectoryIndex /index.php
<Directory /var/www/public>
AllowOverride None
Order Allow,Deny
Allow from All
FallbackResource /index.php
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

3
docker/docker.sh Normal file
View File

@@ -0,0 +1,3 @@
php bin/console d:m:m --no-interaction
php bin/console cache:clear
exec apache2-foreground

View File

@@ -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