-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
101 lines (78 loc) · 2.97 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
FROM php:7.4-fpm
# Update packages and install composer and PHP dependencies.
RUN apt-get update && \
mkdir -p /usr/share/man/man1 && \
mkdir -p /usr/share/man/man7 && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
postgresql-client \
libpq-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
libbz2-dev \
libzip-dev \
zip \
unzip \
cron \
supervisor \
&& pecl channel-update pecl.php.net \
&& pecl install apcu \
&& pecl install xdebug \
&& pecl install mcrypt-1.0.3 \
&& docker-php-ext-enable xdebug mcrypt
#
COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
# PHP Extensions
RUN docker-php-ext-install zip bz2 pdo_pgsql pdo_mysql pcntl \
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
&& docker-php-ext-install gd
# Time Zone
RUN echo "date.timezone=${PHP_TIMEZONE:-UTC}" > $PHP_INI_DIR/conf.d/date_timezone.ini
# Display errors in stderr
RUN echo "display_errors=stderr" > $PHP_INI_DIR/conf.d/display-errors.ini
# Disable PathInfo
RUN echo "cgi.fix_pathinfo=0" > $PHP_INI_DIR/conf.d/path-info.ini
# Disable expose PHP
RUN echo "expose_php=0" > $PHP_INI_DIR/conf.d/path-info.ini
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Laravel Schedule Cron Job:
RUN echo "* * * * * root /usr/local/bin/php /var/www/app/artisan schedule:run >> /dev/null 2>&1" >> /etc/cron.d/laravel-scheduler
RUN chmod 0644 /etc/cron.d/laravel-scheduler
# Aliases
# docker-compose exec php-fpm art --> php artisan
RUN echo '#!/bin/bash\n/usr/local/bin/php /var/www/artisan "$@"' > /usr/bin/art
RUN chmod +x /usr/bin/art
# docker-compose exec php-fpm migrate --> php artisan migrate
RUN echo '#!/bin/bash\n/usr/local/bin/php /var/www/artisan migrate "$@"' > /usr/bin/migrate
RUN chmod +x /usr/bin/migrate
# Defines Redis as queue database.
ENV QUEUE_DRIVER=redis
ENV QUEUE_CONNECTION=redis
ENV QUEUE_NAME=default
ENV LARAVEL_HORIZON=false
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Use local configuration
COPY laravel-worker.conf.tpl /etc/supervisor/conf.d/laravel-worker.conf.tpl
COPY laravel-horizon.conf.tpl /etc/supervisor/conf.d/laravel-horizon.conf.tpl
# ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ADD . /var/www/app
WORKDIR /var/www/app
COPY ./docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh /
ENTRYPOINT ["docker-entrypoint.sh"]
# # Add user for laravel application
# RUN groupadd -g 1000 www
# RUN useradd -u 1000 -ms /bin/bash -g www www
# # Change current user to www
USER www-data
# # Copy existing application directory contents
# COPY . /var/www
# # Copy existing application directory permissions
COPY --chown=www-data:www-data . .
EXPOSE 9000
CMD ["php-fpm"]
# CMD ["/bin/sh", "-c", "php-fpm -D | tail -f storage/logs/laravel.log"]