Tweaked the Docker configuration

This commit is contained in:
Moritz Heiber 2018-05-28 17:30:36 +02:00
parent 716ce6a588
commit 609ca40e69
4 changed files with 65 additions and 27 deletions

View file

@ -1,6 +1,7 @@
storage storage
data data
Dockerfile Dockerfile
docker-compose.yml
.dockerignore .dockerignore
.git .git
.gitignore .gitignore

View file

@ -1,17 +1,33 @@
FROM php:7.2-fpm-alpine FROM php:7.2.6-fpm-alpine
RUN apk add --no-cache git imagemagick \ ARG COMPOSER_VERSION="1.6.5"
&& apk add --no-cache --virtual .build build-base autoconf imagemagick-dev libtool \ ARG COMPOSER_CHECKSUM="67bebe9df9866a795078bb2cf21798d8b0214f2e0b2fd81f2e907a8ef0be3434"
&& docker-php-ext-install pdo_mysql pcntl \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& apk del --purge .build
RUN curl -sS https://getcomposer.org/installer | php \ RUN apk add --no-cache --virtual .build build-base autoconf imagemagick-dev libtool && \
&& mv composer.phar /usr/local/bin/ \ apk --no-cache add imagemagick git && \
&& ln -s /usr/local/bin/composer.phar /usr/local/bin/composer docker-php-ext-install pdo_mysql pcntl && \
pecl install imagick && \
docker-php-ext-enable imagick pcntl imagick && \
curl -LsS https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar -o /tmp/composer.phar && \
echo "${COMPOSER_CHECKSUM} /tmp/composer.phar" | sha256sum -c - && \
install -m0755 -o root -g root /tmp/composer.phar /usr/bin/composer.phar && \
ln -sf /usr/bin/composer.phar /usr/bin/composer && \
mkdir -p /var/www && \
install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed && \
install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage && \
install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework && \
install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/sessions && \
install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/views && \
install -d -m0755 -o www-data -g www-data /var/www/html/pixelfed/storage/framework/cache && \
rm /tmp/composer.phar && \
apk del --purge .build
WORKDIR /var/www/html COPY --chown=www-data . /var/www/html/pixelfed/
COPY . .
WORKDIR /var/www/html/pixelfed
USER www-data
RUN composer install --prefer-source --no-interaction RUN composer install --prefer-source --no-interaction
VOLUME ["/var/www/html"]
USER root
ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}"

View file

@ -4,7 +4,7 @@ server {
server_name localhost; server_name localhost;
index index.php index.html; index index.php index.html;
root /var/www/html/public; root /var/www/html/pixelfed/public;
location / { location / {
try_files $uri $uri/ /index.php; try_files $uri $uri/ /index.php;

View file

@ -3,37 +3,58 @@ version: '3'
services: services:
nginx: nginx:
image: nginx:alpine image: nginx:alpine
networks:
- internal
- external
ports: ports:
- 3000:80 - 3000:80
volumes: volumes:
- .:/var/www/html - "php-storage:/var/www/html"
- ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf - ./contrib/nginx.conf:/etc/nginx/conf.d/default.conf
depends_on: depends_on:
- php - php
php: php:
build: . build: .
image: pixelfed
volumes: volumes:
- ./storage:/var/www/html/storage - "php-storage:/var/www/html"
depends_on: networks:
- mysql - internal
- redis
environment: environment:
- DB_HOST=mysql - DB_HOST=mysql
- DB_DATABASE=pixelfed - DB_DATABASE=pixelfed
- DB_USERNAME=${DB_USERNAME} - DB_USERNAME=${DB_USERNAME:-pixelfed}
- DB_PASSWORD=${DB_PASSWORD} - DB_PASSWORD=${DB_PASSWORD:-pixelfed}
- REDIS_HOST=redis - REDIS_HOST=redis
- APP_KEY=${APP_KEY} - APP_KEY=${APP_KEY:-app_key}
mysql: mysql:
image: mysql:5.7 image: mysql:5.7
networks:
- internal
environment: environment:
- MYSQL_DATABASE=pixelfed - MYSQL_DATABASE=pixelfed
- MYSQL_USER=${DB_USERNAME} - MYSQL_USER=${DB_USERNAME:-pixelfed}
- MYSQL_PASSWORD=${DB_PASSWORD} - MYSQL_PASSWORD=${DB_PASSWORD:-pixelfed}
- MYSQL_RANDOM_ROOT_PASSWORD="true"
volumes: volumes:
- ./docker-volumes/mysql:/var/lib/mysql - "mysql-data:/var/lib/mysql"
redis: redis:
image: redis:alpine image: redis:alpine
volumes: volumes:
- ./docker-volumes/redis:/data - "redis-data:/data"
... networks:
- internal
volumes:
redis-data:
mysql-data:
php-storage:
networks:
internal:
internal: true
external:
driver: bridge