|
| 1 | +# Use phusion/baseimage with a specific version as base image. |
| 2 | +# See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md for a list of version numbers. |
| 3 | +# FROM phusion/baseimage:<VERSION> |
| 4 | +FROM phusion/baseimage:0.9.19 |
| 5 | + |
| 6 | +# Use baseimage-docker's init system. |
| 7 | +CMD ["/sbin/my_init"] |
| 8 | + |
| 9 | +# BEGIN Build instructions ============================================================================================= |
| 10 | + |
| 11 | +# Enable SSH. |
| 12 | +RUN rm -f /etc/service/sshd/down |
| 13 | + |
| 14 | +# Regenerate SSH host keys. baseimage-docker does not contain any, so you |
| 15 | +# have to do that yourself. You may also comment out this instruction; the |
| 16 | +# init system will auto-generate one during boot. |
| 17 | +RUN /etc/my_init.d/00_regen_ssh_host_keys.sh |
| 18 | + |
| 19 | +# Install nginx mainline. |
| 20 | +# "We recommend that in general you deploy the NGINX mainline branch at all times." - nginx.com |
| 21 | +RUN add-apt-repository -y ppa:nginx/development |
| 22 | +RUN apt-get update |
| 23 | +RUN apt-get -y install nginx |
| 24 | +RUN echo "nginx version: $(nginx -v)" |
| 25 | +RUN echo '\ |
| 26 | +server {\n\ |
| 27 | + listen 80 default_server;\n\ |
| 28 | + listen [::]:80 default_server;\n\ |
| 29 | +\n\ |
| 30 | + root /var/www;\n\ |
| 31 | + index index.php;\n\ |
| 32 | +\n\ |
| 33 | + charset utf-8;\n\ |
| 34 | +\n\ |
| 35 | + server_name _;\n\ |
| 36 | + server_tokens off;\n\ |
| 37 | +\n\ |
| 38 | + location / {\n\ |
| 39 | + try_files $uri $uri/ =404;\n\ |
| 40 | + }\n\ |
| 41 | +\n\ |
| 42 | + location ~ \.php$ {\n\ |
| 43 | + include snippets/fastcgi-php.conf;\n\ |
| 44 | + fastcgi_pass unix:/run/php/php7.0-fpm.sock;\n\ |
| 45 | + }\n\ |
| 46 | +}'\ |
| 47 | +> /etc/nginx/sites-enabled/default |
| 48 | +# Fix: "nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)". |
| 49 | +RUN echo "daemon off;" >> /etc/nginx/nginx.conf |
| 50 | + |
| 51 | +# Install PHP. |
| 52 | +# Avoid "debconf: unable to initialize frontend: Dialog" by using DEBIAN_FRONTEND=noninteractive before install command. |
| 53 | +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install php7.0-fpm |
| 54 | +RUN echo "php version: $(php -v)" |
| 55 | + |
| 56 | +# Add nginx daemon. |
| 57 | +RUN mkdir /etc/service/nginx |
| 58 | +RUN echo '#!/usr/bin/env bash\nnginx' > /etc/service/nginx/run |
| 59 | +RUN chmod +x /etc/service/nginx/run |
| 60 | + |
| 61 | +# Add php-fpm daemon. |
| 62 | +RUN mkdir /etc/service/php-fpm |
| 63 | +RUN echo '#!/usr/bin/env bash\nservice php7.0-fpm start' > /etc/service/php-fpm/run |
| 64 | +RUN chmod +x /etc/service/php-fpm/run |
| 65 | + |
| 66 | +# Add homepage. |
| 67 | +ADD index.php /var/www/ |
| 68 | + |
| 69 | +# END Build instructions =============================================================================================== |
| 70 | + |
| 71 | +# Clean up APT when done. |
| 72 | +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
0 commit comments