197 lines
6.9 KiB
Docker
197 lines
6.9 KiB
Docker
FROM debian:stable-slim
|
|
# FROM bitnami/minideb:latest
|
|
|
|
LABEL maintainer="Ludovic CANDELLIER <ludo@huma.net>"
|
|
|
|
# Set Environment Variables
|
|
ENV DEBIAN_FRONTEND noninteractive
|
|
|
|
# Start as root
|
|
USER root
|
|
|
|
###########################################################################
|
|
# Laradock non-root user:
|
|
###########################################################################
|
|
|
|
# Add a non-root user to prevent files being created with root permissions on host machine.
|
|
ARG PUID=1000
|
|
ENV PUID ${PUID}
|
|
ARG PGID=1000
|
|
ENV PGID ${PGID}
|
|
|
|
RUN groupadd -g ${PGID} laradock; \
|
|
useradd -l -u ${PUID} -g laradock -m laradock; \
|
|
usermod -p "*" laradock -s /bin/bash;
|
|
|
|
ARG LARADOCK_PHP_VERSION
|
|
|
|
# always run apt update when start and after add new source list, then clean up at end.
|
|
RUN apt-get update -yqq; \
|
|
apt-get upgrade -yqq; \
|
|
apt-get -yqq install --no-install-recommends apt-transport-https lsb-release tzdata ca-certificates curl wget \
|
|
apt-utils libzip-dev joe zip unzip rsync openssh-client git mc bzip2 nano default-mysql-client supervisor inetutils-ping mydumper \
|
|
wkhtmltopdf ghostscript jpegoptim optipng pngquant gifsicle chromium chromium-sandbox poppler-utils graphviz
|
|
|
|
COPY ./apt_sources/php.list /etc/apt/sources.list.d/php.list
|
|
|
|
RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg;
|
|
|
|
|
|
RUN apt-get update -yqq; \
|
|
apt install -yqq --no-install-recommends php${LARADOCK_PHP_VERSION}-apcu php${LARADOCK_PHP_VERSION}-bcmath php${LARADOCK_PHP_VERSION}-bz2 php${LARADOCK_PHP_VERSION}-cli php${LARADOCK_PHP_VERSION}-common php${LARADOCK_PHP_VERSION}-curl php${LARADOCK_PHP_VERSION}-dev php${LARADOCK_PHP_VERSION}-gd php${LARADOCK_PHP_VERSION}-igbinary php${LARADOCK_PHP_VERSION}-imagick \
|
|
php${LARADOCK_PHP_VERSION}-intl php${LARADOCK_PHP_VERSION}-mbstring php${LARADOCK_PHP_VERSION}-mcrypt php${LARADOCK_PHP_VERSION}-mysql php${LARADOCK_PHP_VERSION}-opcache php${LARADOCK_PHP_VERSION}-readline php${LARADOCK_PHP_VERSION}-redis php${LARADOCK_PHP_VERSION}-sqlite3 php${LARADOCK_PHP_VERSION}-tidy php${LARADOCK_PHP_VERSION}-uuid php${LARADOCK_PHP_VERSION}-xml php${LARADOCK_PHP_VERSION}-yaml php${LARADOCK_PHP_VERSION}-zip
|
|
|
|
RUN apt-get install -yqq --no-install-recommends nodejs npm
|
|
|
|
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
|
|
|
|
# RUN update-alternatives --install /usr/bin/python python /usr/bin/python2 1
|
|
|
|
###########################################################################
|
|
# Set Timezone
|
|
###########################################################################
|
|
|
|
ARG TZ=UTC
|
|
ENV TZ ${TZ}
|
|
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
|
|
###########################################################################
|
|
# Composer:
|
|
###########################################################################
|
|
|
|
USER root
|
|
|
|
# Install composer and add its bin to the PATH.
|
|
RUN curl -s http://getcomposer.org/installer | php \
|
|
&& echo "export PATH=${PATH}:/var/www/vendor/bin" >> ~/.bashrc \
|
|
&& mv composer.phar /usr/local/bin/composer
|
|
|
|
# Export composer vendor path
|
|
RUN echo "" >> ~/.bashrc && \
|
|
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
|
|
|
|
# Update composer
|
|
ARG COMPOSER_VERSION=2
|
|
ENV COMPOSER_VERSION ${COMPOSER_VERSION}
|
|
RUN set -eux; \
|
|
if [ "$COMPOSER_VERSION" = "1" ] || [ "$COMPOSER_VERSION" = "2" ]; then \
|
|
composer self-update --${COMPOSER_VERSION}; \
|
|
else \
|
|
composer self-update ${COMPOSER_VERSION}; \
|
|
fi
|
|
|
|
USER laradock
|
|
|
|
# Export composer vendor path
|
|
RUN echo "" >> ~/.bashrc && \
|
|
echo 'export PATH="~/.composer/vendor/bin:$PATH"' >> ~/.bashrc
|
|
|
|
###########################################################################
|
|
# Non-root user : PHPUnit path
|
|
###########################################################################
|
|
|
|
# add ./vendor/bin to non-root user's bashrc (needed for phpunit)
|
|
USER laradock
|
|
|
|
RUN echo "" >> ~/.bashrc && \
|
|
echo 'export PATH="/var/www/vendor/bin:$PATH"' >> ~/.bashrc
|
|
|
|
###########################################################################
|
|
# Crontab
|
|
###########################################################################
|
|
|
|
USER root
|
|
|
|
COPY ./crontab /etc/cron.d
|
|
|
|
RUN chmod -R 644 /etc/cron.d
|
|
|
|
|
|
###########################################################################
|
|
# YARN:
|
|
###########################################################################
|
|
|
|
USER laradock
|
|
|
|
RUN curl -o- -L https://yarnpkg.com/install.sh | bash; \
|
|
echo "" >> ~/.bashrc && \
|
|
echo 'export PATH="$HOME/.yarn/bin:$PATH"' >> ~/.bashrc
|
|
|
|
# Add YARN binaries to root's .bashrc
|
|
USER root
|
|
|
|
RUN echo "" >> ~/.bashrc && \
|
|
echo 'export YARN_DIR="/home/laradock/.yarn"' >> ~/.bashrc && \
|
|
echo 'export PATH="$YARN_DIR/bin:$PATH"' >> ~/.bashrc
|
|
|
|
# Add PATH for YARN
|
|
ENV PATH $PATH:/home/laradock/.yarn/bin
|
|
|
|
|
|
RUN npm install -g grunt-cli
|
|
|
|
###########################################################################
|
|
# SUPERVISOR:
|
|
###########################################################################
|
|
ARG INSTALL_SUPERVISOR=false
|
|
|
|
RUN if [ ${INSTALL_SUPERVISOR} = true ]; then \
|
|
if [ ${INSTALL_PYTHON} = true ]; then \
|
|
python -m pip install --upgrade supervisor && \
|
|
echo_supervisord_conf > /etc/supervisord.conf && \
|
|
sed -i 's/\;\[include\]/\[include\]/g' /etc/supervisord.conf && \
|
|
sed -i 's/\;files\s.*/files = supervisord.d\/*.conf/g' /etc/supervisord.conf \
|
|
;fi \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# GIT:
|
|
###########################################################################
|
|
|
|
# RUN git --global config pull.ff only
|
|
|
|
###########################################################################
|
|
# PM2:
|
|
###########################################################################
|
|
|
|
RUN npm install -g pm2
|
|
|
|
###########################################################################
|
|
# NVM
|
|
###########################################################################
|
|
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
|
|
# RUN export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
|
# RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
|
|
###########################################################################
|
|
# Check PHP version:
|
|
###########################################################################
|
|
|
|
# RUN php -v | head -n 1 | grep -q "PHP ${PHP_VERSION}."
|
|
|
|
|
|
#
|
|
#--------------------------------------------------------------------------
|
|
# Final Touch
|
|
#--------------------------------------------------------------------------
|
|
#
|
|
|
|
USER root
|
|
|
|
# Clean up
|
|
RUN apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
|
rm /var/log/lastlog /var/log/faillog
|
|
|
|
# COPY ./supervisord/* /etc/supervisor/conf.d/
|
|
|
|
# Set default work directory
|
|
WORKDIR /var/www
|
|
|
|
USER laradock
|
|
|
|
# RUN git config --global user.email "ludo@huma.net" \
|
|
# git config --global user.name "Ludovic CANDELLIER"
|