Skip to content

Instantly share code, notes, and snippets.

@narate
Created January 12, 2018 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narate/74f015004e800db58e24e2dc1a5f720f to your computer and use it in GitHub Desktop.
Save narate/74f015004e800db58e24e2dc1a5f720f to your computer and use it in GitHub Desktop.
Just a Dockerfile to build php7 with composer, nginx, and openssh-server. Please use this Dockerfile for development only

Build and Run

docker build -t wow .
chmod +x start.sh
docker run -d --restart=always \
  --name wow \
  -p 8000:80 \
  -p 2200:22 \
  -v $(pwd)/default.conf:/etc/nginx/sites-available/default \
  -v $(pwd)/start.sh:/start.sh \
  -v $(pwd)/html:/var/www/html \
  wow /start.sh
  
echo '<?php phpinfo(); ?>' > html/info.php
curl localhost:8000/info.php

** PLAESE USE SSH AND KEY AUTHENTICATION **

docker exec -it wow bash
# ssh-keygen
# cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
# exit
docker cp wow:/root/.ssh/id_rsa .
chmod 400 id_rsa
ssh -i id_rsa root@server-ip -p 2200
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
FROM php:7-fpm
MAINTAINER Narate Ketram <rate@tel.co.th>
RUN apt-get update && apt-get install openssh-server nginx-extras vim zlib1g-dev -y
RUN docker-php-ext-install zip
RUN cd /tmp && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && php composer-setup.php && php -r "unlink('composer-setup.php');"
RUN cp /tmp/composer.phar /usr/bin/composer
#!/bin/bash
service nginx start
service ssh start
php-fpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment