Skip to content

Commit 15aaeba

Browse files
Xantios KrugorXantios Krugor
authored andcommitted
Initial commit
0 parents  commit 15aaeba

File tree

8 files changed

+175
-0
lines changed

8 files changed

+175
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

Dockerfile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM ubuntu:20.04
2+
3+
LABEL maintainer="Xantios Krugor"
4+
5+
# Set noninteractive flag for setups
6+
ENV DEBIAN_FRONTEND noninteractive
7+
8+
# Set timezone
9+
ENV TZ=UTC
10+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
11+
12+
# Install dependencies
13+
RUN apt-get update && apt install -y vim gnupg curl ca-certificates zip unzip git sqlite3 software-properties-common inetutils-ping build-essential neofetch
14+
15+
# Install PHP 8
16+
RUN add-apt-repository -y ppa:ondrej/php && add-apt-repository ppa:ondrej/nginx-mainline && apt-get update && apt-get -y install php8.0-cli php8.0-dev php8.0-pgsql php8.0-mbstring php8.0 php8.0-mysql php8.0-gd php8.0-xdebug php8.0-fpm
17+
18+
# Install nginx
19+
RUN apt-get update && apt-get -y install -y nginx
20+
21+
# Install Composer
22+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && chmod +x /usr/local/bin/composer
23+
24+
# Install maple
25+
RUN composer global require xantios/maple
26+
27+
# FPM Config:
28+
# /etc/php8.0/fpm/php-fpm.conf
29+
# /etc/php/8.0/fpm/conf.d/*
30+
#
31+
# Pool config is in:
32+
# /etc/php/8.0/fpm/pool.d/www.conf
33+
34+
# Setup listen
35+
RUN sed -i "s+listen = /run/php/php8.0-fpm.sock+listen = 9000+g" /etc/php/8.0/fpm/pool.d/www.conf
36+
37+
# Setup pid
38+
RUN sed -i "s+pid = /run/php/php8.0-fpm.pid+pid = /var/run/php-fpm.pid+g" /etc/php/8.0/fpm/php-fpm.conf
39+
40+
# Copy Maple conf
41+
COPY ./maple-config.php /maple-config.php
42+
43+
# Copy VHOST
44+
COPY ./vhost.conf /etc/nginx/sites-available/default
45+
46+
# Tell nginx to not log output to a file
47+
RUN sed -i "s+access_log /var/log/nginx/access.log;+access_log stdout;+g" /etc/nginx/nginx.conf && \
48+
sed -i "s+error_log /var/log/nginx/error.log;+error_log stderr;+g" /etc/nginx/nginx.conf
49+
50+
# Setup xDebug / step debugging
51+
COPY xdebug.ini /etc/php/8.0/mods-available/xdebug.ini
52+
53+
# To run webpack and other utilitys NodeJS is rather usefull
54+
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get -y install nodejs
55+
56+
# Just to have a bit of a nicer shell
57+
COPY dot_bashrc /root/.bashrc
58+
59+
# Nginx
60+
EXPOSE 80
61+
62+
# Maple
63+
EXPOSE 8100
64+
65+
# FPM
66+
EXPOSE 9000
67+
68+
ENTRYPOINT [ "/root/.config/composer/vendor/bin/maple" ];

build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
docker rm -f phpdev
4+
docker rmi $(docker images phpdev -q)
5+
6+
docker build . -t phpdev
7+
8+
docker run \
9+
--name phpdev \
10+
-v $PWD/test_app:/var/www/html/ \
11+
-p 8080:80 \
12+
-p 8100:8100 \
13+
phpdev

dot_bashrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
alias ll='ls -l'
2+
alias la='ls -la'
3+
4+
export GREP_OPTIONS=' — color=auto'
5+
export EDITOR=vim
6+
7+
export PS1="\[\033[38;5;8m\][\$?]\[$(tput sgr0)\] \[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;253m\]\A\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;9m\]\h\[$(tput sgr0)\]\[\033[38;5;7m\]@\[$(tput sgr0)\]\[\033[38;5;6m\]\u\[$(tput sgr0)\] \W \\$ \[$(tput sgr0)\]"
8+
9+
neofetch

maple-config.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
return [
4+
// Host to listen on (defaults to 127.0.0.1)
5+
'host' => '0.0.0.0',
6+
7+
// Port for web interface to listen on (defaults to 8100)
8+
'port' => 8100,
9+
10+
// Verbose logging
11+
'verbose' => true,
12+
13+
// Tasks available
14+
'tasks' => [
15+
[
16+
'name' => "Nginx",
17+
'retries' => -1,
18+
'autostart' => true,
19+
'cmd' => 'nginx -g "daemon off; error_log /dev/stdout info;"'
20+
],
21+
[
22+
'name' => "PHP-FPM",
23+
'retries' => -1,
24+
'autostart' => true,
25+
'cmd' => 'php-fpm8.0 -F'
26+
],
27+
]
28+
];

test_app/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
print "Hello world! Im running PHP ".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION." on Docker ".PHP_EOL;
4+
print "xDebug version: ".phpversion('xdebug');
5+
6+
phpinfo();

vhost.conf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## /etc/nginx/sites-available/default
2+
3+
server {
4+
listen 80 default_server;
5+
listen [::]:80 default_server;
6+
7+
add_header X-Frame-Options "SAMEORIGIN";
8+
add_header X-Content-Type-Options "nosniff";
9+
10+
# Set root
11+
root /var/www/html;
12+
index index.php index.html index.htm index.nginx-debian.html;
13+
14+
charset utf-8;
15+
16+
server_name _;
17+
18+
location / {
19+
# First attempt to serve request as file, then
20+
# as directory, then fall back to displaying a 404.
21+
try_files $uri $uri/ =404;
22+
}
23+
24+
# pass PHP scripts to FastCGI server
25+
location ~ \.php$ {
26+
# With php-fpm (or other unix sockets):
27+
# fastcgi_pass unix:/run/php/php7.4-fpm.sock;
28+
# With php-cgi (or other tcp sockets):
29+
fastcgi_pass 127.0.0.1:9000;
30+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
31+
include fastcgi_params;
32+
}
33+
34+
location = /favicon.ico { access_log off; log_not_found off; }
35+
location = /robots.txt { access_log off; log_not_found off; }
36+
37+
location ~ /\.ht {
38+
deny all;
39+
}
40+
41+
location ~ /\.(?!well-known).* {
42+
deny all;
43+
}
44+
}

xdebug.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
zend_extension=xdebug
2+
3+
[xdebug]
4+
xdebug.mode=develop,debug
5+
xdebug.client_host=host.docker.internal
6+
xdebug.start_with_request=yes

0 commit comments

Comments
 (0)