Dockerfile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. FROM busybox:latest
  2. # copy代码文件
  3. COPY . /var/application
  4. COPY ./deploy/deploy-prod/env.example /var/application/.env
  5. # 安装php-fpm
  6. FROM php:7.1-fpm-alpine
  7. # 配置apk的源
  8. RUN echo "http://mirrors.aliyun.com/alpine/v3.10/main/" > /etc/apk/repositories \
  9. && echo "http://mirrors.aliyun.com/alpine/v3.10/community/" >> /etc/apk/repositories \
  10. && apk upgrade --update
  11. # 安装其他软件
  12. RUN apk add wget \
  13. git \
  14. supervisor \
  15. zlib-dev \
  16. nginx \
  17. && docker-php-ext-install pdo_mysql zip \
  18. && mkdir /run/nginx
  19. # copy supervisor文件
  20. COPY ./deploy/supervisord/supervisord.conf /etc/supervisord.conf
  21. COPY ./deploy/supervisord/supervisord.d/ /etc/supervisord.d/
  22. # copy nginx配置文件
  23. COPY ./deploy/nginx/nginx.conf /etc/nginx/nginx.conf
  24. # 安装composer
  25. RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
  26. && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
  27. && php -r "unlink('composer-setup.php');" \
  28. && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
  29. # copy crontab文件
  30. COPY ./deploy/crontab/laravel /etc/cron.d/laravel
  31. RUN chmod -R 644 /etc/cron.d/laravel
  32. # Apply cron job
  33. RUN crontab /etc/cron.d/laravel
  34. ENV COMPOSER_ALLOW_SUPERUSER 1
  35. COPY --from=0 /var/application /var/www/application
  36. WORKDIR /var/www/application
  37. RUN composer install --ignore-platform-reqs --no-dev
  38. COPY ./deploy/run.sh /usr/local/bin/run.sh
  39. RUN sed -i 's/www-data/nginx/g' /usr/local/etc/php-fpm.d/www.conf \
  40. && mkdir -p /usr/share/nginx \
  41. && ln -s /var/www/application/public /usr/share/nginx/html \
  42. && chmod +x /usr/local/bin/run.sh
  43. CMD ["run.sh"]