From 77ca794cf0ca8854a8ebd3c27f9a84f19bf22ad7 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Sun, 20 May 2018 15:02:29 +0200 Subject: [PATCH] Add simple docker deployment --- .dockerignore | 7 +++++++ .gitignore | 1 + Dockerfile | 17 +++++++++++++++++ contrib/nginx.conf | 22 ++++++++++++++++++++++ docker-compose.yml | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 contrib/nginx.conf create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..5d4b8fcc0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +storage +data +Dockerfile +.dockerignore +.git +.gitignore +.env diff --git a/.gitignore b/.gitignore index 67c0aeabe..d52873f29 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /.idea /.vscode /.vagrant +/docker-volumes Homestead.json Homestead.yaml npm-debug.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..b64f08282 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM php:7.2-fpm-alpine + +RUN apk add --no-cache git imagemagick \ + && apk add --no-cache --virtual .build build-base autoconf imagemagick-dev libtool \ + && docker-php-ext-install pdo_mysql \ + && pecl install imagick \ + && docker-php-ext-enable imagick \ + && apk del --purge .build + +RUN curl -sS https://getcomposer.org/installer | php \ + && mv composer.phar /usr/local/bin/ \ + && ln -s /usr/local/bin/composer.phar /usr/local/bin/composer + +WORKDIR /var/www/html +COPY . . +RUN composer install --prefer-source --no-interaction +ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" diff --git a/contrib/nginx.conf b/contrib/nginx.conf new file mode 100644 index 000000000..c39103d5a --- /dev/null +++ b/contrib/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name localhost; + + index index.php index.html; + root /var/www/html/public; + + location / { + try_files $uri $uri/ /index.php; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..d9c39bd2f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,39 @@ +--- +version: '3' +services: + nginx: + image: nginx:alpine + ports: + - 3000:80 + volumes: + - .:/var/www/html + - ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf + depends_on: + - php + php: + build: . + volumes: + - ./storage:/var/www/html/storage + depends_on: + - mysql + - redis + environment: + - DB_HOST=mysql + - DB_DATABASE=pixelfed + - DB_USERNAME=${DB_USERNAME} + - DB_PASSWORD=${DB_PASSWORD} + - REDIS_HOST=redis + - APP_KEY=${APP_KEY} + mysql: + image: mysql:5.7 + environment: + - MYSQL_DATABASE=pixelfed + - MYSQL_USER=${DB_USERNAME} + - MYSQL_PASSWORD=${DB_PASSWORD} + volumes: + - ./docker-volumes/mysql:/var/lib/mysql + redis: + image: redis:alpine + volumes: + - ./docker-volumes/redis:/data +...