-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5af37d1
commit 46e6b1f
Showing
4 changed files
with
190 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[supervisord] | ||
nodaemon=true | ||
user=%(ENV_USER)s | ||
logfile=/var/log/supervisor/supervisord.log | ||
pidfile=/var/run/supervisord.pid | ||
|
||
[unix_http_server] | ||
file=/var/run/supervisor.sock | ||
|
||
[supervisorctl] | ||
serverurl=unix:///var/run/supervisor.sock | ||
|
||
[rpcinterface:supervisor] | ||
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,148 @@ | ||
ARG ALPINE_VERSION=3.19 | ||
FROM alpine:${ALPINE_VERSION} | ||
LABEL Maintainer="Tim de Pater <code@trafex.nl>" | ||
LABEL Description="Lightweight container with Nginx 1.24 & PHP 8.3 based on Alpine Linux." | ||
# Setup document root | ||
WORKDIR /var/www/html | ||
|
||
# Install packages and remove default server definition | ||
RUN apk add --no-cache \ | ||
curl \ | ||
nginx \ | ||
php83 \ | ||
php83-ctype \ | ||
php83-curl \ | ||
php83-dom \ | ||
php83-fileinfo \ | ||
php83-fpm \ | ||
php83-gd \ | ||
php83-intl \ | ||
php83-mbstring \ | ||
php83-mysqli \ | ||
php83-opcache \ | ||
php83-openssl \ | ||
php83-phar \ | ||
php83-session \ | ||
php83-tokenizer \ | ||
php83-xml \ | ||
php83-xmlreader \ | ||
php83-xmlwriter \ | ||
supervisor | ||
|
||
# Configure nginx - http | ||
COPY .docker/config/nginx.conf /etc/nginx/nginx.conf | ||
# Configure nginx - default server | ||
COPY .docker/config/conf.d /etc/nginx/conf.d/ | ||
|
||
# Configure PHP-FPM | ||
ENV PHP_INI_DIR /etc/php83 | ||
COPY .docker/config/fpm-pool.conf ${PHP_INI_DIR}/php-fpm.d/www.conf | ||
COPY .docker/config/php.ini ${PHP_INI_DIR}/conf.d/custom.ini | ||
|
||
# Configure supervisord | ||
COPY .docker/config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
|
||
# Make sure files/folders needed by the processes are accessable when they run under the nobody user | ||
RUN chown -R nobody.nobody /var/www/html /run /var/lib/nginx /var/log/nginx | ||
|
||
# Create symlink for php | ||
RUN ln -s /usr/bin/php83 /usr/bin/php | ||
|
||
# Switch to use a non-root user from here on | ||
USER nobody | ||
|
||
# Add application | ||
COPY --chown=nobody . /var/www/html/ | ||
|
||
# Expose the port nginx is reachable on | ||
EXPOSE 80 | ||
|
||
# Let supervisord start nginx & php-fpm | ||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] | ||
|
||
# Configure a healthcheck to validate that everything is up&running | ||
HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping || exit 1 | ||
# Accepted values: 8.3 - 8.2 | ||
ARG PHP_VERSION=8.3 | ||
|
||
ARG COMPOSER_VERSION=latest | ||
|
||
ARG NODE_VERSION=20-alpine | ||
|
||
########################################### | ||
|
||
FROM composer:${COMPOSER_VERSION} AS vendor | ||
|
||
FROM php:${PHP_VERSION}-cli-alpine | ||
|
||
LABEL maintainer="SMortexa <seyed.me720@gmail.com>" | ||
LABEL org.opencontainers.image.title="Laravel Octane Dockerfile" | ||
LABEL org.opencontainers.image.description="Production-ready Dockerfile for Laravel Octane" | ||
LABEL org.opencontainers.image.source=https://github.com/exaco/laravel-octane-dockerfile | ||
LABEL org.opencontainers.image.licenses=MIT | ||
|
||
ARG WWWUSER=1000 | ||
ARG WWWGROUP=1000 | ||
ARG TZ=UTC | ||
|
||
ENV TERM=xterm-color \ | ||
WITH_HORIZON=false \ | ||
WITH_SCHEDULER=false \ | ||
OCTANE_SERVER=swoole \ | ||
USER=octane \ | ||
ROOT=/var/www/html \ | ||
COMPOSER_FUND=0 \ | ||
COMPOSER_MAX_PARALLEL_HTTP=24 | ||
|
||
WORKDIR ${ROOT} | ||
|
||
SHELL ["/bin/sh", "-eou", "pipefail", "-c"] | ||
|
||
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \ | ||
&& echo ${TZ} > /etc/timezone | ||
|
||
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ | ||
|
||
RUN apk update; \ | ||
apk upgrade; \ | ||
apk add --no-cache \ | ||
curl \ | ||
wget \ | ||
nano \ | ||
ncdu \ | ||
procps \ | ||
ca-certificates \ | ||
supervisor \ | ||
libsodium-dev \ | ||
# Install PHP extensions | ||
&& install-php-extensions \ | ||
bz2 \ | ||
pcntl \ | ||
mbstring \ | ||
bcmath \ | ||
sockets \ | ||
pgsql \ | ||
pdo_pgsql \ | ||
opcache \ | ||
exif \ | ||
pdo_mysql \ | ||
zip \ | ||
intl \ | ||
gd \ | ||
redis \ | ||
rdkafka \ | ||
memcached \ | ||
igbinary \ | ||
ldap \ | ||
swoole \ | ||
&& docker-php-source delete \ | ||
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/* | ||
|
||
RUN arch="$(apk --print-arch)" \ | ||
&& case "$arch" in \ | ||
armhf) _cronic_fname='supercronic-linux-arm' ;; \ | ||
aarch64) _cronic_fname='supercronic-linux-arm64' ;; \ | ||
x86_64) _cronic_fname='supercronic-linux-amd64' ;; \ | ||
x86) _cronic_fname='supercronic-linux-386' ;; \ | ||
*) echo >&2 "error: unsupported architecture: $arch"; exit 1 ;; \ | ||
esac \ | ||
&& wget -q "https://github.com/aptible/supercronic/releases/download/v0.2.29/${_cronic_fname}" \ | ||
-O /usr/bin/supercronic \ | ||
&& chmod +x /usr/bin/supercronic \ | ||
&& mkdir -p /etc/supercronic \ | ||
&& echo "*/1 * * * * php ${ROOT}/artisan schedule:run --no-interaction" > /etc/supercronic/laravel | ||
|
||
RUN addgroup -g ${WWWGROUP} ${USER} \ | ||
&& adduser -D -h ${ROOT} -G ${USER} -u ${WWWUSER} -s /bin/sh ${USER} | ||
|
||
RUN mkdir -p /var/log/supervisor /var/run/supervisor \ | ||
&& chown -R ${USER}:${USER} ${ROOT} /var/log /var/run \ | ||
&& chmod -R a+rw ${ROOT} /var/log /var/run | ||
|
||
RUN cp ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini | ||
|
||
USER ${USER} | ||
|
||
COPY --chown=${USER}:${USER} --from=vendor /usr/bin/composer /usr/bin/composer | ||
COPY --chown=${USER}:${USER} composer.json composer.lock ./ | ||
|
||
RUN composer install \ | ||
--no-dev \ | ||
--no-interaction \ | ||
--no-autoloader \ | ||
--no-ansi \ | ||
--no-scripts \ | ||
--audit | ||
|
||
COPY --chown=${USER}:${USER} . . | ||
|
||
RUN mkdir -p \ | ||
storage/framework/sessions \ | ||
storage/framework/views \ | ||
storage/framework/cache \ | ||
storage/framework/testing \ | ||
storage/logs \ | ||
bootstrap/cache && chmod -R a+rw storage | ||
|
||
COPY --chown=${USER}:${USER} .docker/supervisord.conf /etc/supervisor/ | ||
COPY --chown=${USER}:${USER} .docker/octane/Swoole/supervisord.swoole.conf /etc/supervisor/conf.d/ | ||
COPY --chown=${USER}:${USER} .docker/supervisord.*.conf /etc/supervisor/conf.d/ | ||
COPY --chown=${USER}:${USER} .docker/php.ini ${PHP_INI_DIR}/conf.d/99-octane.ini | ||
COPY --chown=${USER}:${USER} .docker/start-container /usr/local/bin/start-container | ||
|
||
RUN composer install \ | ||
--classmap-authoritative \ | ||
--no-interaction \ | ||
--no-ansi \ | ||
--no-dev \ | ||
&& composer clear-cache | ||
|
||
COPY .env.example ./.env | ||
|
||
RUN php artisan key:generate | ||
|
||
RUN chmod +x /usr/local/bin/start-container | ||
|
||
RUN cat .docker/utilities.sh >> ~/.bashrc | ||
|
||
EXPOSE 8000 | ||
|
||
ENTRYPOINT ["start-container"] | ||
|
||
HEALTHCHECK --start-period=5s --interval=2s --timeout=5s --retries=8 CMD php artisan octane:status || exit 1 |