Procházet zdrojové kódy

Created docker-related files

Alejandro Celaya před 7 roky
rodič
revize
072371d459

+ 2 - 0
data/infra/database/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 6 - 0
data/infra/db.Dockerfile

@@ -0,0 +1,6 @@
+FROM mysql:5.7
+MAINTAINER Alejandro Celaya <alejandro@alejandrocelaya.com>
+
+# Enable remote access (default is localhost only, we change this
+# otherwise our database would not be reachable from outside the container)
+RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf

+ 5 - 0
data/infra/nginx.Dockerfile

@@ -0,0 +1,5 @@
+FROM nginx:1.11.6-alpine
+MAINTAINER Alejandro Celaya <alejandro@alejandrocelaya.com>
+
+# Delete default nginx vhost
+RUN rm /etc/nginx/conf.d/default.conf

+ 2 - 0
data/infra/nginx/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 75 - 0
data/infra/php.Dockerfile

@@ -0,0 +1,75 @@
+FROM php:7.1-fpm-alpine
+MAINTAINER Alejandro Celaya <alejandro@alejandrocelaya.com>
+
+RUN apk update
+
+# Install common php extensions
+RUN docker-php-ext-install pdo_mysql
+RUN docker-php-ext-install iconv
+RUN docker-php-ext-install mbstring
+RUN docker-php-ext-install calendar
+
+RUN apk add --no-cache --virtual sqlite-libs
+RUN apk add --no-cache --virtual sqlite-dev
+RUN docker-php-ext-install pdo_sqlite
+
+RUN apk add --no-cache --virtual icu-dev
+RUN docker-php-ext-install intl
+
+RUN apk add --no-cache --virtual zlib-dev
+RUN docker-php-ext-install zip
+
+RUN apk add --no-cache --virtual libmcrypt-dev
+RUN docker-php-ext-install mcrypt
+
+RUN apk add --no-cache --virtual libpng-dev
+RUN docker-php-ext-install gd
+
+# Install redis extension
+ADD https://github.com/phpredis/phpredis/archive/php7.tar.gz /tmp/phpredis.tar.gz
+RUN mkdir -p /usr/src/php/ext/redis\
+  && tar xf /tmp/phpredis.tar.gz -C /usr/src/php/ext/redis --strip-components=1
+# configure and install
+RUN docker-php-ext-configure redis\
+  && docker-php-ext-install redis
+# cleanup
+RUN rm /tmp/phpredis.tar.gz
+
+# Install APCu extension
+ADD https://pecl.php.net/get/apcu-5.1.3.tgz /tmp/apcu.tar.gz
+RUN mkdir -p /usr/src/php/ext/apcu\
+  && tar xf /tmp/apcu.tar.gz -C /usr/src/php/ext/apcu --strip-components=1
+# configure and install
+RUN docker-php-ext-configure apcu\
+  && docker-php-ext-install apcu
+# cleanup
+RUN rm /tmp/apcu.tar.gz
+
+# Install APCu-BC extension
+ADD https://pecl.php.net/get/apcu_bc-1.0.3.tgz /tmp/apcu_bc.tar.gz
+RUN mkdir -p /usr/src/php/ext/apcu-bc\
+  && tar xf /tmp/apcu_bc.tar.gz -C /usr/src/php/ext/apcu-bc --strip-components=1
+# configure and install
+RUN docker-php-ext-configure apcu-bc\
+  && docker-php-ext-install apcu-bc
+# cleanup
+RUN rm /tmp/apcu_bc.tar.gz
+
+# Load APCU.ini before APC.ini
+RUN rm /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
+RUN echo extension=apcu.so > /usr/local/etc/php/conf.d/20-php-ext-apcu.ini
+
+# Install xdebug
+ADD https://pecl.php.net/get/xdebug-2.5.0 /tmp/xdebug.tar.gz
+RUN mkdir -p /usr/src/php/ext/xdebug\
+  && tar xf /tmp/xdebug.tar.gz -C /usr/src/php/ext/xdebug --strip-components=1
+# configure and install
+RUN docker-php-ext-configure xdebug\
+  && docker-php-ext-install xdebug
+# cleanup
+RUN rm /tmp/xdebug.tar.gz
+
+# Install composer
+RUN php -r "readfile('https://getcomposer.org/installer');" | php
+RUN chmod +x composer.phar
+RUN mv composer.phar /usr/local/bin/composer

+ 1 - 0
data/infra/php.ini

@@ -0,0 +1 @@
+date.timezone = Europe/Madrid

+ 21 - 0
data/infra/vhost.conf

@@ -0,0 +1,21 @@
+server {
+    listen 80 default_server;
+    server_name shlink.local;
+    root /home/shlink/www/public;
+    index index.php;
+
+    charset utf-8;
+    error_log /home/shlink/www/data/infra/nginx/shlink.error.log;
+
+    location / {
+        try_files $uri $uri/ /index.php$is_args$args;
+    }
+
+    location ~ \.php$ {
+        root /home/shlink/www/public;
+        fastcgi_split_path_info ^(.+\.php)(/.+)$;
+        fastcgi_pass shlink_php:9000;
+        fastcgi_index index.php;
+        include fastcgi.conf;
+    }
+}

+ 40 - 0
docker-compose.yml

@@ -0,0 +1,40 @@
+version: '2'
+
+services:
+    shlink_nginx:
+        container_name: shlink_nginx
+        build:
+            context: .
+            dockerfile: ./data/infra/nginx.Dockerfile
+        ports:
+            - "8000:80"
+        volumes:
+            - ./:/home/shlink/www
+            - ./data/infra/vhost.conf:/etc/nginx/conf.d/shlink-vhost.conf
+        links:
+            - shlink_php
+
+    shlink_php:
+        container_name: shlink_php
+        build:
+            context: .
+            dockerfile: ./data/infra/php.Dockerfile
+        volumes:
+            - ./:/home/shlink/www
+            - ./data/infra/php.ini:/usr/local/etc/php/php.ini
+        links:
+            - shlink_db
+
+    shlink_db:
+        container_name: shlink_db
+        build:
+            context: .
+            dockerfile: ./data/infra/db.Dockerfile
+        ports:
+            - "3307:3306"
+        volumes:
+            - ./:/home/shlink/www
+            - ./data/infra/database:/var/lib/mysql
+        environment:
+            MYSQL_ROOT_PASSWORD: root
+            MYSQL_DATABASE: shlink

+ 2 - 0
indocker

@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+docker exec -it shlink_php /bin/sh -c "cd /home/shlink/www && $*"