File tree 7 files changed +149
-0
lines changed
7 files changed +149
-0
lines changed Original file line number Diff line number Diff line change
1
+ /application /web /bundles /
2
+ /application /app /bootstrap.php.cache
3
+ /application /app /cache /*
4
+ /application /app /config /parameters.yml
5
+ /application /app /logs /*
6
+ ! application /app /cache /.gitkeep
7
+ ! application /app /logs /.gitkeep
8
+ /application /app /phpunit.xml
9
+ /application /build /
10
+ /application /vendor /
11
+ /application /bin /
12
+ /.idea /
Original file line number Diff line number Diff line change
1
+ <VirtualHost *:80>
2
+ ServerName example.com
3
+ ServerAlias www.example.com
4
+
5
+ DocumentRoot /var/www/html/application/web
6
+ <Directory /var/www/html/application/web>
7
+ AllowOverride None
8
+ Order Allow,Deny
9
+ Allow from All
10
+
11
+ <IfModule mod_rewrite.c>
12
+ Options -MultiViews
13
+ RewriteEngine On
14
+ RewriteCond %{REQUEST_FILENAME} !-f
15
+ RewriteRule ^(.*)$ app.php [QSA,L]
16
+ </IfModule>
17
+ </Directory>
18
+
19
+ # uncomment the following lines if you install assets as symlinks
20
+ # or run into problems when compiling LESS/Sass/CoffeeScript assets
21
+ <Directory /var/www/html/application>
22
+ Options FollowSymlinks
23
+ </Directory>
24
+
25
+ # optionally disable the RewriteEngine for the asset directories
26
+ # which will allow apache to simply reply with a 404 when files are
27
+ # not found instead of passing the request into the full symfony stack
28
+ <Directory /var/www/html/application/web/bundles>
29
+ <IfModule mod_rewrite.c>
30
+ RewriteEngine Off
31
+ </IfModule>
32
+ </Directory>
33
+ ErrorLog /var/log/apache2/application_error.log
34
+ CustomLog /var/log/apache2/application_access.log combined
35
+ </VirtualHost>
Original file line number Diff line number Diff line change
1
+ FROM php:7.0-apache
2
+
3
+ ENV DEBIAN_FRONTEND noninteractive
4
+
5
+ # Configure Apache and installs other services
6
+ RUN a2enmod rewrite \
7
+ && apt-get update \
8
+ && echo 'ServerName localhost' >> /etc/apache2/apache2.conf \
9
+ && apt-get install -y curl git \
10
+ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
11
+
12
+ # Install extra php libraries
13
+ RUN docker-php-ext-install pdo pdo_mysql
14
+
15
+ # Add custom Apache config file
16
+ ADD 000-default.conf /etc/apache2/sites-available/000-default.conf
17
+
18
+ # Add project files
19
+ COPY application/ /var/www/html/application
20
+
21
+ # Add addition bach script file for configuring Symfony Application
22
+ COPY run.sh /run.sh
23
+ RUN chmod 0755 /run.sh
24
+
25
+ WORKDIR /var/www/html/application
26
+ RUN composer install --no-interaction --prefer-source
27
+ EXPOSE 80
28
+ CMD ["/run.sh" ]
Original file line number Diff line number Diff line change
1
+ A Docker image based on Ubuntu, running PHP7 on Apache2 using a MySQL Database for a Symfony2 Web Application.
2
+
3
+ ###Technical requirements
4
+ - Install Docker
5
+ The host machine must have Docker installed in order to build and run the Container.
6
+ Instructions on how to install Docker can be found on the official [ page] ( https://docs.docker.com/engine/installation/ )
7
+ - Install Docker Compose
8
+ Docker Compose helps on orchestrating the communication between the ` application ` container and ` mysql ` container.
9
+ Instructions on how to install Docker Compose can be found on the official [ page] ( https://docs.docker.com/compose/install/ ) .
10
+
11
+ ###Installation
12
+
13
+ - Clone source code
14
+ On the host machine clone the GitHub(` git ` is required to be installed) repository by executing:
15
+
16
+ ```
17
+ git clone https://github.com/redjanym/docker-apache-php7-mysql-symfony2.git
18
+ ```
19
+
20
+ - Add the Symfony2 Application
21
+ On the ** application** directory setup the Symfony2 App. Do not install the Vendor packages, composer takes care of it during the building process.
22
+
23
+
24
+ - Run Docker
25
+ Go to the root directory of project and execute command:
26
+
27
+ ```
28
+ docker-compose up
29
+ ```
30
+ - Modify your ` hosts ` file on he host machine by adding the virtual host:
31
+
32
+ ```
33
+ 127.0.0.1 www.example.com
34
+ ```
35
+
36
+ > The docker installation exposes ports ** 80** and ** 3306** so this 2 ports must be free on the host machine
37
+
38
+ ###Installed packages
39
+
40
+ - Ubuntu Server 16.04(official docker image ** php:7.0-apache** )
41
+ - Apache2(official docker image ** php:7.0-apache** )
42
+ - PHP7(official docker image ** php:7.0-apache** )
43
+ - MySQL(official docker image, latest stable version)
44
+ - CURL
45
+ - Composer
Original file line number Diff line number Diff line change
1
+ version : ' 2'
2
+ services :
3
+ mysql :
4
+ image : mysql
5
+ environment :
6
+ MYSQL_ROOT_PASSWORD : root
7
+ volumes :
8
+ - db:/var/lib/mysql
9
+ application :
10
+ build : .
11
+ ports :
12
+ - ' 80:80'
13
+ depends_on :
14
+ - mysql
15
+ volumes :
16
+ db:
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # Prepare Symfony Project
4
+ chown -R www-data:www-data app/cache
5
+ chown -R www-data:www-data app/logs
6
+ rm -rf app/log/* app/cache/*
7
+ php app/console doctrine:database:create
8
+ php app/console doctrine:schema:update --force
9
+ php app/console cache:clear --env=prod
10
+ chmod 777 -R app/cache app/logs
11
+
12
+ source /etc/apache2/envvars
13
+ exec apache2 -D FOREGROUND
You can’t perform that action at this time.
0 commit comments