Last active
November 21, 2018 21:00
-
-
Save dracken/de0c495572f600b8b2f0190306946332 to your computer and use it in GitHub Desktop.
Basic Docker Composer File for Nginx, Php7, MariaDB, PhPMyAdmin, MailDev, Redis, Kibana and Elasticsearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"github-oauth": { | |
"github.com": "<YOUR GITHUB PRIVATE TOKEN HERE>" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Docker Compose File | |
# | |
# Requires Docker 18.06.0+ | |
# | |
## | |
version: '3.7' | |
services: | |
# See https://hub.docker.com/_/nginx/ | |
nginx-api: | |
build: docker/nginx/. | |
image: custom-nginx | |
hostname: nginx.local | |
container_name: nginx | |
ports: | |
- "8000:80" | |
volumes: | |
- .:/var/www/:rw | |
- ./logs:/var/log/nginx | |
depends_on: | |
- php-api | |
links: | |
- php-api | |
command: [nginx-debug, '-g', 'daemon off;'] | |
environment: | |
HOSTNAME: nginx.local | |
# See https://hub.docker.com/_/mariadb/ | |
mysql: | |
build: docker/mysql/. | |
image: custom-mysql | |
hostname: mysql.local | |
container_name: mysql | |
environment: | |
- MYSQL_ROOT_PASSWORD=${DBROOT} | |
- MYSQL_DATABASE=${DBNAME} | |
- MYSQL_USER=${DBUSER} | |
- MYSQL_PASSWORD=${DBPASS} | |
volumes: | |
- .docker/data/db:/var/lib/mysql | |
env_file: | |
- api/.env | |
ports: | |
- "3306:3306" | |
# See https://hub.docker.com/_/php/ | |
php-api: | |
build: docker/php/. | |
image: custom-php-fpm | |
hostname: php.local | |
container_name: php | |
volumes: | |
- .:/var/www/:rw | |
- ./logs:/var/log | |
environment: | |
maildev_host: maildev | |
HOSTNAME: php.local | |
depends_on: | |
- maildev | |
- mysql | |
links: | |
- mysql | |
env_file: | |
- api/.env | |
tty: true | |
expose: | |
- 9000 | |
# See https://hub.docker.com/r/phpmyadmin/phpmyadmin/ | |
phpmyadmin: | |
image: phpmyadmin/phpmyadmin | |
hostname: phpmyadmin.local | |
container_name: phpmyadmin | |
ports: | |
- "8080:80" | |
links: | |
- mysql | |
depends_on: | |
- mysql | |
environment: | |
HOSTNAME: phpmyadmin.local | |
PMA_HOST: mysql | |
# See https://github.com/djfarrelly/MailDev/blob/master/docs/docker.md | |
maildev: | |
image: djfarrelly/maildev | |
hostname: maildev.local | |
container_name: maildev | |
ports: | |
- "8002:80" | |
environment: | |
HOSTNAME: maildev.local | |
# See https://hub.docker.com/_/redis/ | |
# See https://docs.docker.com/samples/library/redis/ | |
redis: | |
build: docker/redis/. | |
image: custom-redis | |
hostname: redis.local | |
container_name: redis | |
ports: | |
- "6379:6379" | |
# See https://www.npmjs.com/package/redis-commander | |
redis-commander: | |
container_name: redis-commander | |
hostname: redis_commander | |
container_name: redis_commander | |
image: rediscommander/redis-commander:latest | |
restart: always | |
environment: | |
- REDIS_HOSTS=local:redis:6379 | |
ports: | |
- "8081:8081" | |
# See https://elk-docker.readthedocs.io/ | |
# For viewing through elastic search JSON display, navigate to: http://127.0.0.1:9200/_search?pretty | |
elasticsearch: | |
image: sebp/elk | |
hostname: elasticsearch.local | |
container_name: elasticsearch | |
ports: | |
- "5601:5601" # Kibana web interface | |
- "9200:9200" # Elasticsearch JSON interface | |
- "9300:9300" # Elasticsearch Transport interface | |
- "5044:5044" # Logstash Beats interface | |
environment: | |
HOSTNAME: elasticsearch.local | |
MAX_MAP_COUNT: 262144 | |
# See https://hub.docker.com/r/prima/filebeat | |
filebeat: | |
image: custom-filebeat | |
build: docker/filebeat/. | |
hostname: filebeat.local | |
container_name: filebeat | |
# See https://hub.docker.com/_/composer/ | |
composer: | |
#image: custom-composer | |
#build: docker/stayalert_api_composer/. | |
image: "composer" | |
container_name: stayalert_api_composer | |
hostname: stayalert_api_composer.local | |
volumes: | |
- .:/var/www/:rw | |
- /var/www/vendor/ | |
- /var/www/api/vendor/ | |
# - composer.auth.json:/root/.composer/auth.json | |
working_dir: /var/www/api | |
#command: update #["install --ignore-platform-requs", "dump-autoload --optimize"] | |
volumes: | |
esdata1: | |
mysql: | |
composer: | |
nginx: | |
php: | |
networks: | |
default: | |
name: private_network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
php /var/www/api/bin/console doctrine:database:drop --force | |
php /var/www/api/bin/console doctrine:database:create -vvv | |
php /var/www/api/bin/console doctrine:schema:create -vvv | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP_ENV=dev #test, qa, prod | |
TIMEZONE=America/Denver | |
MYSQL_ROOT_PASSWORD=mysupersecrectrootpassword #change | |
MYSQL_DATABASE=mylocaldatabase #change | |
MYSQL_USER=mylocaluser #change | |
MYSQL_PASSWORD=mylocalpassword #change | |
MYSQL_HOST=mysql | |
MYSQL_PORT=3306 | |
COMPOSER_AUTH='{"github-oauth": {"github.com": "<YOUR GITHUB PRIVATE TOKEN HERE>"}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
types { | |
text/html html htm shtml; | |
text/css css; | |
text/xml xml; | |
image/gif gif; | |
image/jpeg jpeg jpg; | |
application/javascript js; | |
application/atom+xml atom; | |
application/rss+xml rss; | |
text/mathml mml; | |
text/plain txt; | |
text/vnd.sun.j2me.app-descriptor jad; | |
text/vnd.wap.wml wml; | |
text/x-component htc; | |
image/png png; | |
image/svg+xml svg svgz; | |
image/tiff tif tiff; | |
image/vnd.wap.wbmp wbmp; | |
image/webp webp; | |
image/x-icon ico; | |
image/x-jng jng; | |
image/x-ms-bmp bmp; | |
font/woff woff; | |
font/woff2 woff2; | |
application/java-archive jar war ear; | |
application/json json; | |
application/mac-binhex40 hqx; | |
application/msword doc; | |
application/pdf pdf; | |
application/postscript ps eps ai; | |
application/rtf rtf; | |
application/vnd.apple.mpegurl m3u8; | |
application/vnd.google-earth.kml+xml kml; | |
application/vnd.google-earth.kmz kmz; | |
application/vnd.ms-excel xls; | |
application/vnd.ms-fontobject eot; | |
application/vnd.ms-powerpoint ppt; | |
application/vnd.oasis.opendocument.graphics odg; | |
application/vnd.oasis.opendocument.presentation odp; | |
application/vnd.oasis.opendocument.spreadsheet ods; | |
application/vnd.oasis.opendocument.text odt; | |
application/vnd.openxmlformats-officedocument.presentationml.presentation | |
pptx; | |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | |
xlsx; | |
application/vnd.openxmlformats-officedocument.wordprocessingml.document | |
docx; | |
application/vnd.wap.wmlc wmlc; | |
application/x-7z-compressed 7z; | |
application/x-cocoa cco; | |
application/x-java-archive-diff jardiff; | |
application/x-java-jnlp-file jnlp; | |
application/x-makeself run; | |
application/x-perl pl pm; | |
application/x-pilot prc pdb; | |
application/x-rar-compressed rar; | |
application/x-redhat-package-manager rpm; | |
application/x-sea sea; | |
application/x-shockwave-flash swf; | |
application/x-stuffit sit; | |
application/x-tcl tcl tk; | |
application/x-x509-ca-cert der pem crt; | |
application/x-xpinstall xpi; | |
application/xhtml+xml xhtml; | |
application/xspf+xml xspf; | |
application/zip zip; | |
application/octet-stream bin exe dll; | |
application/octet-stream deb; | |
application/octet-stream dmg; | |
application/octet-stream iso img; | |
application/octet-stream msi msp msm; | |
audio/midi mid midi kar; | |
audio/mpeg mp3; | |
audio/ogg ogg; | |
audio/x-m4a m4a; | |
audio/x-realaudio ra; | |
video/3gpp 3gpp 3gp; | |
video/mp2t ts; | |
video/mp4 mp4; | |
video/mpeg mpeg mpg; | |
video/quicktime mov; | |
video/webm webm; | |
video/x-flv flv; | |
video/x-m4v m4v; | |
video/x-mng mng; | |
video/x-ms-asf asx asf; | |
video/x-ms-wmv wmv; | |
video/x-msvideo avi; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MariaDB database server configuration file. | |
# | |
# You can copy this file to one of: | |
# - "/etc/mysql/my.cnf" to set global options, | |
# - "~/.my.cnf" to set user-specific options. | |
# | |
# One can use all long options that the program supports. | |
# Run program with --help to get a list of available options and with | |
# --print-defaults to see which it would actually understand and use. | |
# | |
# For explanations see | |
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html | |
# This will be passed to all mysql clients | |
# It has been reported that passwords should be enclosed with ticks/quotes | |
# escpecially if they contain "#" chars... | |
# Remember to edit /etc/mysql/debian.cnf when changing the socket location. | |
[client] | |
protocol = tcp | |
port = 3306 | |
socket = /var/run/mysqld/mysqld.sock | |
# Here is entries for some specific programs | |
# The following values assume you have at least 32M ram | |
# This was formally known as [safe_mysqld]. Both versions are currently parsed. | |
[mysqld_safe] | |
socket = /var/run/mysqld/mysqld.sock | |
nice = 0 | |
[mysqld] | |
# | |
# * Basic Settings | |
# | |
user = mysql | |
pid-file = /var/run/mysqld/mysqld.pid | |
socket = /var/run/mysqld/mysqld.sock | |
port = 3306 | |
bind-address = 0.0.0.0 | |
basedir = /usr | |
datadir = /var/lib/mysql | |
tmpdir = /tmp | |
lc_messages_dir = /usr/share/mysql | |
lc_messages = en_US | |
skip-external-locking | |
default_storage_engine = InnoDB | |
# | |
# * Fine Tuning | |
# | |
max_connections = 100 | |
connect_timeout = 5 | |
wait_timeout = 600 | |
lock_wait_timeout = 600 | |
max_allowed_packet = 64M | |
thread_cache_size = 128 | |
bulk_insert_buffer_size = 16M | |
tmp_table_size = 64M | |
max_heap_table_size = 64M | |
# | |
# * MyISAM | |
# | |
# This replaces the startup script and checks MyISAM tables if needed | |
# the first time they are touched. On error, make copy and try a repair. | |
myisam_recover = FORCE,BACKUP | |
key_buffer_size = 128M | |
table_open_cache = 400 | |
# | |
# * Query Cache Configuration | |
# | |
query_cache_size = 0 | |
query_cache_type = OFF | |
# | |
# * Logging and Replication | |
# | |
general_log_file = /var/lib/mysql/mysql.log | |
general_log = 1 | |
# | |
log_error = mysql.err | |
# we do want to know about network errors and such | |
log_warnings = 2 | |
# | |
# Enable the slow query log to see queries with especially long duration | |
slow_query_log = 0 | |
#slow_query_log_file = /var/log/mysql/mariadb-slow.log | |
#long_query_time = 2 | |
#log_slow_rate_limit = 1000 | |
#log_slow_verbosity = query_plan | |
#log-queries-not-using-indexes | |
# | |
# The following can be used as easy to replay backup logs or for replication. | |
# note: if you are setting up a replication slave, see README.Debian about | |
# other settings you may need to change. | |
#server-id = 1 | |
log_bin = /var/lib/mysql/mariadb-bin | |
log_bin_index = /var/lib/mysql/mariadb-bin.index | |
# not fab for performance, but safer | |
sync_binlog = 0 | |
expire_logs_days = 10 | |
max_binlog_size = 8M | |
# slaves | |
#relay_log = /var/log/mysql/relay-bin | |
#relay_log_index = /var/log/mysql/relay-bin.index | |
#relay_log_info_file = /var/log/mysql/relay-bin.info | |
#log_slave_updates | |
#read_only | |
# | |
# If applications support it, this stricter sql_mode prevents some | |
# mistakes like inserting invalid dates etc. | |
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL | |
# | |
# * InnoDB | |
# | |
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. | |
# Read the manual for more InnoDB related options. There are many! | |
# you can't just change log file size, requires special procedure | |
innodb_log_file_size = 8M | |
innodb_buffer_pool_size = 8M | |
innodb_log_buffer_size = 64M | |
innodb_file_per_table = 1 | |
innodb_strict_mode = 1 | |
innodb_open_files = 400 | |
innodb_io_capacity = 400 | |
innodb_flush_method = O_DIRECT | |
# | |
# * plugins | |
# | |
plugin-load-add=ha_connect.so | |
plugin-load-add=metadata_lock_info.so | |
plugin-load-add=query_response_time.so | |
plugin-load-add=locales.so | |
[mysqldump] | |
quote-names | |
create-options | |
extended-insert | |
quick | |
max_allowed_packet = 64M | |
flush-logs | |
single-transaction | |
[mysql] | |
no-auto-rehash | |
[isamchk] | |
key_buffer_size = 64M | |
sort_buffer_size = 64M | |
read_buffer = 32M | |
write_buffer = 32M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# | |
# Generate Docker MariaDB/MySQL container | |
# | |
## | |
FROM mariadb:latest | |
MAINTAINER dracken@drackenslair.com | |
COPY db_setup.sh //home/mysql/bin/db_setup.sh | |
COPY my.cnf /etc/mysql/my.cnf | |
RUN apt-get update && apt-get --assume-yes install vim nmap | |
RUN chmod 755 /home/mysql/bin/db_setup.sh \ | |
&& /home/mysql/bin/db_setup.sh \ | |
&& echo "alias ll='ls -hAlt --color=auto'" >> ~/.bashrc | |
RUN echo "America/Denver" > /etc/timezone | |
RUN dpkg-reconfigure -f noninteractive tzdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error_log "/var/log/stayalert_api.error.log" debug; | |
pid /var/log/nginx.pid; | |
worker_rlimit_nofile 8192; | |
events { | |
worker_connections 4096; ## Default: 1024 | |
} | |
http { | |
#index index.html index.htm index.php; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] $status ' | |
'"$request" $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/stayalert_api.access.log main; | |
sendfile on; | |
tcp_nopush on; | |
server_names_hash_bucket_size 128; # this seems to be required for some vhosts | |
server { | |
listen 80; | |
listen [::]:80 ipv6only=on; | |
# listen 8000; | |
# listen [::]:8000 ipv6only=on; | |
server_name .stayalert_api.local; | |
access_log /var/log/stayalert_api.access.log main; | |
root /var/www/html/; | |
location / { | |
# try to serve file directly, fallback to index.php | |
try_files $uri /index.php$is_args$args ; | |
} | |
# location ~ ^/index\.php(/|$) { | |
# fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; | |
# fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
# include fastcgi_params; | |
# optionally set the value of the environment variables used in the application | |
# fastcgi_param APP_ENV prod; | |
# fastcgi_param APP_SECRET <app-secret-id>; | |
# fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name"; | |
# When you are using symlinks to link the document root to the | |
# current version of your application, you should pass the real | |
# application path instead of the path to the symlink to PHP | |
# FPM. | |
# Otherwise, PHP's OPcache may not properly detect changes to | |
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 | |
# for more information). | |
# fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
# fastcgi_param DOCUMENT_ROOT $realpath_root; | |
# Prevents URIs that include the front controller. This will 404: | |
# http://domain.tld/index.php/some-path | |
# Remove the internal directive to allow URIs like this | |
# internal; | |
# } | |
location ~ ^/index\.php(/|$) { | |
fastcgi_pass stayalert_api_php:9000; | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
fastcgi_param DOCUMENT_ROOT $realpath_root; | |
fastcgi_buffering off; | |
# Prevents URIs that include the front controller. This will 404: | |
# http://domain.tld/index.php/some-path | |
# Remove the internal directive to allow URIs like this | |
internal; | |
} | |
# return 404 for all other php files not matching the front controller | |
# this prevents access to other php files you don't want to be accessible. | |
location ~ \.php$ { | |
return 404; | |
} | |
# error_log /var/log/nginx/project_error.log; | |
# access_log /var/log/nginx/project_access.log; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# | |
# Generate Nginx Docker container | |
# | |
## | |
FROM nginx:latest | |
MAINTAINER dracken@drackenslair.com | |
COPY nginx.conf /etc/nginx/nginx.conf | |
COPY mime.types /etc/nginx/mime.types | |
RUN echo "alias ll='ls -hAlt --color=auto'" >> ~/.bashrc | |
RUN echo "America/Denver" > /etc/timezone | |
RUN dpkg-reconfigure -f noninteractive tzdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# | |
# Generate PHP Docker Container | |
# | |
## | |
FROM php:7.2-fpm | |
MAINTAINER dracken@drackenslair.com | |
ENV COMPOSER_ALLOW_SUPERUSER 1 | |
ENV COMPOSER_HOME /tmp | |
ENV COMPOSER_VERSION 1.7.3 | |
#RUN groupadd -r swuser -g 433 && \ | |
# useradd -u 431 -r -g swuser -d <homedir> -s /sbin/nologin -c "Docker image user" swuser && \ | |
# chown -R swuser:swuser <homedir> | |
#ADD www.conf /etc/php/7.1/fpm/pool.d/www.conf | |
#ADD php-fpm.conf /etc/php/7.1/fpm/php-fpm.conf | |
#USER swuser | |
RUN echo "alias ll='ls -hAlt --color=auto'" >> ~/.bashrc \ | |
&& echo "America/Denver" > /etc/timezone \ | |
&& dpkg-reconfigure -f noninteractive tzdata \ | |
&& apt -yqq update \ | |
&& apt -yqq install libxml2-dev \ | |
&& apt-get install -yqq --no-install-recommends git zip unzip zlib1g-dev \ | |
&& docker-php-ext-install pdo_mysql > /dev/null \ | |
&& docker-php-ext-install xml > /dev/null \ | |
&& docker-php-ext-install zip > /dev/null | |
# Install XDebug | |
RUN pecl config-set php_ini /usr/local/etc/php/php.ini-development \ | |
&& pecl install xdebug \ | |
# && echo 'zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so' > /usr/local/etc/php/php.ini-development | |
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini | |
# Install Composer | |
RUN curl --silent --show-error https://getcomposer.org/installer | php && \ | |
mv -f composer.phar /usr/local/bin/composer | |
COPY composer.auth.json /root/.composer/auth.json | |
#&& \ | |
# ./composer update | |
WORKDIR /var/www/api | |
# Copy over shell scripts | |
COPY doctrine_setup.sh /tmp/doctrine_setup.sh | |
COPY composer_setup.sh /tmp/composer_setup.sh | |
COPY composer.auth.json /root/.composer/auth.json | |
# Run the Doctrine Setup | |
RUN chmod 755 /tmp/doctrine_setup.sh \ | |
&& /tmp/doctrine_setup.sh | |
#Run the Composer Setup | |
RUN chmod 755 /tmp/composer_setup.sh \ | |
&& /tmp/composer_setup.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# | |
# Generate Redis and Install Redis Commander | |
# | |
## | |
FROM redis:latest | |
MAINTAINER dracken@drackenslair.com | |
RUN apt-get update -q \ | |
&& echo "alias ll='ls -hAlt --color=auto'" >> ~/.bashrc | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment