Skip to content

Ubuntu, PPAs, tweaks. #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0235789
resolved conflict
datadarius Dec 23, 2016
fcfc8cf
Merge pull request #6 from datadarius/improvements
datadarius Dec 26, 2016
fdf65a2
merged
datadarius Dec 27, 2016
f774a0f
Merge remote-tracking branch 'upstream/master'
datadarius Dec 27, 2016
a9a7605
Merge pull request #7 from nerdpress-org/master
datadarius Dec 27, 2016
61c3941
Merge branch 'master' of https://github.com/datadarius/docker-sf3
datadarius Dec 27, 2016
c4d7086
changed mailcatcher docker image to https://hub.docker.com/r/schickli…
datadarius Dec 27, 2016
3bed430
Merge remote-tracking branch 'nerdpress-org/master'
datadarius Dec 27, 2016
9800b44
removing apache-php dir.
datadarius Dec 27, 2016
5dfa27e
working ondrej repos and composer
datadarius Dec 28, 2016
abd0c53
-
datadarius Dec 28, 2016
3e4b8e3
basic symfony working.
datadarius Dec 28, 2016
2382f09
added sqlite and intl php packages
datadarius Dec 28, 2016
06db6b4
enabled http2 support
datadarius Dec 28, 2016
5fec364
a2enmod http2
datadarius Dec 28, 2016
d421192
added sudo command and permissions.
datadarius Dec 28, 2016
dd8bd21
working sudo command for www-data user.
datadarius Dec 28, 2016
53e272b
removed docker pecl scripts
datadarius Dec 28, 2016
73892a0
README changes.
datadarius Dec 28, 2016
f121dc9
README format
datadarius Dec 28, 2016
0f15541
-
datadarius Dec 28, 2016
f86bb73
format.
datadarius Dec 28, 2016
d1fb33d
documentation debug and services.
datadarius Dec 28, 2016
138f782
added various references
datadarius Dec 28, 2016
87f52c0
label corrections
datadarius Dec 29, 2016
2eebe5f
added nerdpress zsh theme file.
datadarius Jan 1, 2017
1f4ef4c
described zsh and permissions, added bash option.
datadarius Jan 1, 2017
2d98109
doku.
datadarius Jan 1, 2017
30dbbb4
fixed theme
datadarius Jan 1, 2017
96b8a0e
format fix.
datadarius Jan 1, 2017
85cc5e8
...
datadarius Jan 1, 2017
549987a
documentation.
datadarius Jan 1, 2017
b495d41
added .htaccess in docker-sf3 root directory.
datadarius Feb 14, 2017
22298b8
clean php 7.1 setup
datadarius Feb 14, 2017
fe3689e
removed xdebug
datadarius Feb 14, 2017
ba2f6fa
xdebug disabled, php.ini disabled.
datadarius Feb 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 46 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ permission-hassle free <sup>:tm:</sup> [» More](/Resources/doc/permissions.md)
git clone https://github.com/nerdpress-org/docker-sf3.git docker-sf3
cp -r docker-sf3/docker /path/to/your/symfony-project/

## Please Notice

This software compilation is ment for local development purpose only.

## Usage

cd /path/to/your/symfony-project/docker
Expand All @@ -32,34 +36,63 @@ Open the browser: [http://[docker-host]:8080](http://[docker-host]:8080)

![toolbar](Resources/doc/toolbar.png)

### PHP

PHP7 is used.
## Development Webserver (sf_web)

### PHP7 on Apache 2.4 (http2 enabled)
from the [Ondřej Surý PPA](https://launchpad.net/~ondrej)
running on [Ubuntu:Xenial](https://hub.docker.com/_/ubuntu/) Docker Image.

### Debugging

Xdebug and Blackfire.io support are included by default.
[» How to configure](Resources/doc/debug.md)

### DB
### zsh default shell
[oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) is the default shell.

The Dockerfile can be found here:
(/docker/sf_web Docker

MySql is used.
## DB (sf_db)
Official [MySQL:5](https://hub.docker.com/r/mysql/mysql-server/) Docker is used.
Use the name of the service as the database host in your connection settings:

```yml
database_driver: pdo_mysql
database_host: db
database_port: 3306
database_name: sf3
database_user: sf3
database_password: sf3
database_driver: pdo_mysql
database_host: db
database_port: 3306
database_name: sf3
database_user: sf3
database_password: sf3
```

Its configured to be open for access from outside,
so if you prefer to use MySql Workbench on the host, use the containers IP as host.
Find the IP with: `docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' $(docker ps -q)`
Find the IP with:
`docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' $(docker ps -q)`

Otherwise use phpmyadmin on [http://[docker-host]:8081](http://[docker-host]:8081)
### Otherwise use official phpmyadmin docker on [http://[docker-host]:8081](http://[docker-host]:8081)

### Other Services
## Other Services

* [Elasticsearch](Resources/doc/services.md)
* [Mailcatcher SMTP](Resources/doc/services.md)


## Customizing Environment
* Locale is en_US.UTF-8
* Timezone is set to Europe/Berlin

## ToDos

* Create a _.htaccess_ file in the docker folder, to prevent funny things.
* Make docker_sf3 directly _installable_ into a Symfony project.
* Add more tests for the additional services.
* Tweak Nerdpress zsh theme
* Dynamically add php version to sf_web env.
* Dynamically populate db credentials for sf3 via environment.
* Set up names to enable service discovery.
* Set up automated certificate creation and clarify to make it persist.
* Create an image (e.g. on quay.io) to speed up installation.
* Set up continous image builds. (e.g. on cve or othe source images changes)
12 changes: 11 additions & 1 deletion Resources/doc/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@ Blackfire client and agent are provided by the official Docker image.
The probe is integrated in the PHP container.
Get the Blackfire Bookmarklet and enter your credentials in *docker-env* and thats it.

Happy Profiling :)
Happy Profiling :)

## Switching between Blackfire and Xdebug

Do not run xdebug and blackfire simoultanously.
In order ot enable or disable xdebug / blackfire, please run

```yml
sudo phpdismod xdebug
sudo phpenmod blackfire
```
8 changes: 7 additions & 1 deletion Resources/doc/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ by changing the user id of the _www-data_ user to the current host user id.

This should work on linux, mac or windows systems.

For running symfony commands via cli, log into the _sf_web_ container as _www-data_
For running symfony commands via cli, log into the _sf_web_ container as _www-data_

## Warning
The user www-data is member of the sudo group as well as adm.
Furthermore sudo does not require a password for the sudo action. (See sf_web/Dockerfile.dist)
This is only to simplify local development.
Do not run this on a server, please.
12 changes: 7 additions & 5 deletions Resources/doc/services.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@

#### Elasticsearch

### Elasticsearch
Uses the official [Elasticsearch Alpine](https://hub.docker.com/_/elasticsearch) image.
```yml
host: elasticsearch
port: 9200
```

#### Mailcatcher SMTP

### Mailcatcher SMTP
[mailcatcher](https://rubygems.org/gems/mailcatcher/) helps to deal with inbound and outbound email.
```yml
host: mailcatcher
port: 1025
```

Webinterface on http://[yourhost*]:1080
Webinterface on http://[yourhost*]:1080

It uses the [tiny-mailcatcher](https://github.com/datadarius/tiny-mailcatcher) Docker Image.
11 changes: 11 additions & 0 deletions Resources/doc/zsh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Nerdpress loves oh-my-zsh with rubyrussell Theme

_zsh_ is set as the default shell.
The [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) Framework is enabled be default.
robyrussell is our favorite theme but we needed a hostname at the prompt.
Therefore whe modified the [» Theme](/sf_web/nerdpress.zsh-theme)
A few Aliases to simplify web development are configured in [» zshrc.dist](/sf_web/zshrc.dist)


## Enable bash
If you prefer bash, you need to edit the docker.sh and replace zsh with bash
1 change: 1 addition & 0 deletions docker/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Require all denied
8 changes: 4 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ services:
container_name: "sf_web"
ports:
- 8080:80 #apache
- 9001:9000 #xdebug
- 8081:443 #apache secure

volumes:
- "../:/var/www/html"
- "~/.composer:/var/www/.composer"
- ./sf_web/zshrc.dist:/var/www/.zshrc:ro
- ./sf_web/nerdpress.zsh-theme:/var/www/.oh-my-zsh/themes/nerdpress.zsh-theme:ro
links:
- db
- elasticsearch
Expand Down Expand Up @@ -57,7 +59,6 @@ services:
- PMA_USER=root
- PMA_PASSWORD=root


#elasticsearch
elasticsearch:
image: "elasticsearch:1.3"
Expand All @@ -67,11 +68,10 @@ services:
ports:
- 9201:9200


#mailcatcher
mailcatcher:
container_name: "sf_mailcatcher"
image: yappabe/mailcatcher
image: schickling/mailcatcher
ports:
- 1025:1025
- 1080:1080
Expand Down
3 changes: 3 additions & 0 deletions docker/sf_web/000-default.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#This enables http2 support. h2 ist http2 via TLS, h2c is http2 via TCP,...
#The sorting order decides on the connection (left first)
Protocols h2c http/1.1
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
Expand Down
68 changes: 32 additions & 36 deletions docker/sf_web/Dockerfile.dist
Original file line number Diff line number Diff line change
@@ -1,61 +1,55 @@
FROM php:7-apache
FROM ubuntu:xenial

#Enable necessary Apache modules
RUN a2enmod rewrite
LABEL org.nerdpress.version="1-beta"
LABEL vendor="nerdpress.org"
LABEL org.nerdpress.release-date="2017-02-14"
LABEL org.nerdpress.version.is-production="false"

#Change your timezone below. Full list of timezones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
RUN echo Europe/Berlin > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
ENV DEBIAN_FRONTEND noninteractive
# Todo, set PHP_VERSION ENV through a php query.

#Append software required during runtime here.
RUN RUNTIME_PKGS="locales zsh curl vim git zip mcrypt mysql-client htop ssh-client libicu52 libjpeg62-turbo libpng12-0 libfreetype6" \
&& apt-get update && apt-get install -y --no-install-recommends $RUNTIME_PKGS \
RUN BASE_PKGS="ca-certificates locales zsh bash curl vim git zip mcrypt htop ssh-client sudo" \
&& apt-get update && apt-get install -y --no-install-recommends $BASE_PKGS \
&& apt-get autoremove -y && apt-get clean -y \
&& locale-gen en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

#PECL
ADD docker-php-pecl-install /usr/local/bin/
RUN chmod u+x /usr/local/bin/docker-php-pecl-install

#Append software required during build here.
RUN BUILD_PKGS="zlib1g-dev libicu-dev g++ libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev make" \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_PKGS \
&& docker-php-ext-install -j$(nproc) iconv mcrypt mbstring exif zip opcache pdo_mysql pcntl \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
&& docker-php-pecl-install xdebug \
&& apt-get autoremove -y $BUILD_PKGS \
&& apt-get clean -y \
#Change your timezone below. Full list of timezones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
RUN echo Europe/Berlin > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata

#Add Ondrej Sury PPAs (https://launchpad.net/~ondrej) and install Apache+PHP
RUN WEB_PKGS="apache2 nghttp2 php7.1 php7.1-mysql php7.1-sqlite php7.1-intl php-zip php-json php-curl php-xml libapache2-mod-php7.1" \
&& echo deb http://ppa.launchpad.net/ondrej/apache2/ubuntu xenial main > /etc/apt/sources.list.d/ondrej-apache2.list \
&& echo deb http://ppa.launchpad.net/ondrej/php/ubuntu xenial main > /etc/apt/sources.list.d/ondrej-php.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-key E5267A6C \
&& apt-get update && apt-get install -y --no-install-recommends $WEB_PKGS \
&& apt-get autoremove -y && apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

#Configure xdebug.
RUN sed -i '1 a xdebug.remote_autostart=true' /usr/local/etc/php/conf.d/docker-php-pecl-xdebug.ini
RUN sed -i '1 a xdebug.remote_connect_back=1 ' /usr/local/etc/php/conf.d/docker-php-pecl-xdebug.ini
RUN sed -i '1 a xdebug.remote_enable=1' /usr/local/etc/php/conf.d/docker-php-pecl-xdebug.ini
RUN sed -i '1 a xdebug.max_nesting_level = 1200' /usr/local/etc/php/conf.d/docker-php-pecl-xdebug.ini
#Enable necessary Apache modules
RUN a2enmod rewrite http2

#Install blackfire.
RUN export VERSION=`php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;"` \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/${VERSION} \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
&& mv /tmp/blackfire-*.so `php -r "echo ini_get('extension_dir');"`/blackfire.so \
&& echo "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707" > /usr/local/etc/php/conf.d/blackfire.ini \
&& echo "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707" > /etc/php/7.1/mods-available/blackfire.ini \
&& rm -rf /tmp/* /var/tmp/*

#Install composer.
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer global require hirak/prestissimo \
&& rm -rf /tmp/* /var/tmp/*
&& composer global require hirak/prestissimo \
&& rm -rf /tmp/* /var/tmp/*

#Populate Environment
##Populate Environment
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
COPY php.ini /usr/local/etc/php/
COPY zshrc.dist /var/www/.zshrc
#COPY php.ini /usr/local/etc/php/

#Overtake www-data
RUN usermod -u $USER_ID www-data -s /bin/zsh
#Overtake www-data, set zsh shell, append (!) groups sudo and adm
RUN usermod -u $USER_ID www-data -s /bin/zsh -a -G sudo,adm
RUN echo "www-data ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers

#Install oh-my-zsh
ENV TERM=xterm
Expand All @@ -66,4 +60,6 @@ RUN chgrp -R www-data /var/www
RUN chmod -R g+rwx /var/www
RUN umask 0007

WORKDIR /var/www/html
EXPOSE 80 443
WORKDIR /var/www/html
ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
36 changes: 0 additions & 36 deletions docker/sf_web/docker-php-pecl-install

This file was deleted.

7 changes: 7 additions & 0 deletions docker/sf_web/nerdpress.zsh-theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)@$HOST# '

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
14 changes: 7 additions & 7 deletions docker/sf_web/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1932,11 +1932,11 @@ opcache.fast_shutdown=1
; tab-width: 4
; End:

[Xdebug]
#[Xdebug]
;zend_extension="<path to php_xdebug.dll>"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=192.168.2.165
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.var_display_max_depth = 5;
#xdebug.remote_enable=1
#xdebug.remote_port=9000
#xdebug.remote_host=192.168.2.165
#xdebug.profiler_enable=1
#xdebug.profiler_output_dir="/tmp/xdebug"
#xdebug.var_display_max_depth = 5;
4 changes: 2 additions & 2 deletions docker/sf_web/zshrc.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export ZSH=/var/www/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
ZSH_THEME="nerdpress"

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
Expand All @@ -20,7 +20,7 @@ ZSH_THEME="robbyrussell"
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
Expand Down