You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
447 lines
14 KiB
447 lines
14 KiB
#
|
|
#--------------------------------------------------------------------------
|
|
# Image Setup
|
|
#--------------------------------------------------------------------------
|
|
#
|
|
# To edit the 'workspace' base Image, visit its repository on Github
|
|
# https://github.com/Laradock/workspace
|
|
#
|
|
# To change its version, see the available Tags on the Docker Hub:
|
|
# https://hub.docker.com/r/laradock/workspace/tags/
|
|
#
|
|
# Note: Base Image name format {image-tag}-{php-version}
|
|
#
|
|
|
|
ARG PHP_VERSION
|
|
|
|
# FROM laradock/workspace:2.2-${PHP_VERSION}
|
|
FROM letsdockerize/laradock-workspace:2.4-${PHP_VERSION}
|
|
|
|
LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"
|
|
|
|
# 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}
|
|
|
|
# always run apt update when start and after add new source list, then clean up at end.
|
|
RUN set -xe; \
|
|
apt-get update -yqq && \
|
|
pecl channel-update pecl.php.net && \
|
|
groupadd -g ${PGID} laradock && \
|
|
useradd -u ${PUID} -g laradock -m laradock -G docker_env && \
|
|
usermod -p "*" laradock -s /bin/bash && \
|
|
apt-get install -yqq \
|
|
apt-utils \
|
|
#
|
|
#--------------------------------------------------------------------------
|
|
# Mandatory Software's Installation
|
|
#--------------------------------------------------------------------------
|
|
#
|
|
# Mandatory Software's such as ("php-cli", "git", "vim", ....) are
|
|
# installed on the base image 'laradock/workspace' image. If you want
|
|
# to add more Software's or remove existing one, you need to edit the
|
|
# base image (https://github.com/Laradock/workspace).
|
|
#
|
|
# next lines are here becase there is no auto build on dockerhub see https://github.com/laradock/laradock/pull/1903#issuecomment-463142846
|
|
libzip-dev zip unzip \
|
|
# Install the zip extension
|
|
php${PHP_VERSION}-zip \
|
|
# nasm
|
|
nasm && \
|
|
php -m | grep -q 'zip'
|
|
|
|
#
|
|
#--------------------------------------------------------------------------
|
|
# Optional Software's Installation
|
|
#--------------------------------------------------------------------------
|
|
#
|
|
# Optional Software's will only be installed if you set them to `true`
|
|
# in the `docker-compose.yml` before the build.
|
|
# Example:
|
|
# - WORKSPACE_INSTALL_NODE=false
|
|
# - ...
|
|
#
|
|
|
|
###########################################################################
|
|
# Set Timezone
|
|
###########################################################################
|
|
|
|
ARG TZ=Europe/Moscow
|
|
ENV TZ ${TZ}
|
|
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
###########################################################################
|
|
# User Aliases
|
|
###########################################################################
|
|
|
|
USER root
|
|
|
|
COPY ./aliases.sh /root/aliases.sh
|
|
COPY ./aliases.sh /home/laradock/aliases.sh
|
|
|
|
RUN sed -i 's/\r//' /root/aliases.sh && \
|
|
sed -i 's/\r//' /home/laradock/aliases.sh && \
|
|
chown laradock:laradock /home/laradock/aliases.sh && \
|
|
echo "" >> ~/.bashrc && \
|
|
echo "# Load Custom Aliases" >> ~/.bashrc && \
|
|
echo "source ~/aliases.sh" >> ~/.bashrc && \
|
|
echo "" >> ~/.bashrc
|
|
|
|
USER laradock
|
|
|
|
RUN echo "" >> ~/.bashrc && \
|
|
echo "# Load Custom Aliases" >> ~/.bashrc && \
|
|
echo "source ~/aliases.sh" >> ~/.bashrc && \
|
|
echo "" >> ~/.bashrc
|
|
|
|
###########################################################################
|
|
# Composer:
|
|
###########################################################################
|
|
|
|
USER root
|
|
|
|
# Add the composer.json
|
|
COPY ./composer.json /home/laradock/.composer/composer.json
|
|
|
|
# Add the auth.json for magento 2 credentials
|
|
COPY ./auth.json /home/laradock/.composer/auth.json
|
|
|
|
# Make sure that ~/.composer belongs to laradock
|
|
RUN chown -R laradock:laradock /home/laradock/.composer
|
|
|
|
USER laradock
|
|
|
|
# Check if global install need to be ran
|
|
ARG COMPOSER_GLOBAL_INSTALL=false
|
|
ENV COMPOSER_GLOBAL_INSTALL ${COMPOSER_GLOBAL_INSTALL}
|
|
|
|
RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \
|
|
# run the install
|
|
composer global install \
|
|
;fi
|
|
|
|
# Check if auth file is disabled
|
|
ARG COMPOSER_AUTH=false
|
|
ENV COMPOSER_AUTH ${COMPOSER_AUTH}
|
|
|
|
RUN if [ ${COMPOSER_AUTH} = false ]; then \
|
|
# remove the file
|
|
rm /home/laradock/.composer/auth.json \
|
|
;fi
|
|
|
|
ARG COMPOSER_REPO_PACKAGIST
|
|
ENV COMPOSER_REPO_PACKAGIST ${COMPOSER_REPO_PACKAGIST}
|
|
|
|
RUN if [ ${COMPOSER_REPO_PACKAGIST} ]; then \
|
|
composer config -g repo.packagist composer ${COMPOSER_REPO_PACKAGIST} \
|
|
;fi
|
|
|
|
# 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
|
|
|
|
###########################################################################
|
|
# WP CLI:
|
|
###########################################################################
|
|
|
|
# The command line interface for WordPress
|
|
|
|
USER root
|
|
|
|
ARG INSTALL_WP_CLI=false
|
|
|
|
RUN if [ ${INSTALL_WP_CLI} = true ]; then \
|
|
curl -fsSL -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | bash && \
|
|
chmod +x /usr/local/bin/wp \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# xDebug:
|
|
###########################################################################
|
|
|
|
USER root
|
|
|
|
ARG INSTALL_XDEBUG=false
|
|
|
|
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
|
# Load the xdebug extension only with phpunit commands
|
|
apt-get install -y php${PHP_VERSION}-xdebug && \
|
|
sed -i 's/^;//g' /etc/php/${PHP_VERSION}/cli/conf.d/20-xdebug.ini && \
|
|
echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/vendor/bin/phpunit'" >> ~/.bashrc \
|
|
;fi
|
|
|
|
# ADD for REMOTE debugging
|
|
COPY ./xdebug.ini /etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini
|
|
|
|
RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini && \
|
|
sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini && \
|
|
sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini
|
|
|
|
|
|
###########################################################################
|
|
# Additional PHP-extensions:
|
|
###########################################################################
|
|
|
|
RUN pecl install igbinary \
|
|
&& pecl install -a redis
|
|
|
|
###########################################################################
|
|
# ssh:
|
|
###########################################################################
|
|
|
|
ARG INSTALL_SSH=false
|
|
ENV INSTALL_SSH ${INSTALL_SSH}
|
|
|
|
ARG SSH_PASSPHRAZE=12345
|
|
ENV SSH_PASSPHRAZE ${SSH_PASSPHRAZE}
|
|
|
|
RUN ssh-keygen -f /tmp/id_rsa -N ${SSH_PASSPHRAZE}
|
|
|
|
RUN if [ ${INSTALL_SSH} = true ]; then \
|
|
rm -f /etc/service/sshd/down && \
|
|
cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys \
|
|
&& cat /tmp/id_rsa.pub >> /root/.ssh/id_rsa.pub \
|
|
&& cat /tmp/id_rsa >> /root/.ssh/id_rsa \
|
|
&& rm -f /tmp/id_rsa* \
|
|
&& chmod 644 /root/.ssh/authorized_keys /root/.ssh/id_rsa.pub \
|
|
&& chmod 400 /root/.ssh/id_rsa \
|
|
&& cp -rf /root/.ssh /home/laradock \
|
|
&& chown -R laradock:laradock /home/laradock/.ssh \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# fswatch
|
|
###########################################################################
|
|
|
|
ARG INSTALL_FSWATCH=false
|
|
|
|
RUN if [ ${INSTALL_FSWATCH} = true ]; then \
|
|
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 47FE03C1 \
|
|
&& add-apt-repository -y ppa:hadret/fswatch \
|
|
|| apt-get update -yqq \
|
|
&& apt-get -y install fswatch \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# Node / NVM:
|
|
###########################################################################
|
|
|
|
USER laradock
|
|
|
|
# Check if NVM needs to be installed
|
|
ARG INSTALL_NODE=false
|
|
ENV INSTALL_NODE ${INSTALL_NODE}
|
|
ARG NODE_VERSION=node
|
|
ENV NODE_VERSION ${NODE_VERSION}
|
|
ARG INSTALL_NPM_GULP=false
|
|
ARG INSTALL_NPM_BOWER=false
|
|
ARG INSTALL_NPM_VUE_CLI=false
|
|
ARG INSTALL_NPM_ANGULAR_CLI=false
|
|
ARG NPM_REGISTRY
|
|
ENV NPM_REGISTRY ${NPM_REGISTRY}
|
|
ENV NVM_DIR /home/laradock/.nvm
|
|
|
|
RUN if [ ${INSTALL_NODE} = true ]; then \
|
|
# Install nvm (A Node Version Manager)
|
|
mkdir -p $NVM_DIR && \
|
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash \
|
|
&& . $NVM_DIR/nvm.sh \
|
|
&& nvm install ${NODE_VERSION} \
|
|
&& nvm use ${NODE_VERSION} \
|
|
&& nvm alias ${NODE_VERSION} \
|
|
&& if [ ${NPM_REGISTRY} ]; then \
|
|
npm config set registry ${NPM_REGISTRY} \
|
|
;fi \
|
|
&& if [ ${INSTALL_NPM_GULP} = true ]; then \
|
|
npm install -g gulp \
|
|
;fi \
|
|
&& if [ ${INSTALL_NPM_BOWER} = true ]; then \
|
|
npm install -g bower \
|
|
;fi \
|
|
&& if [ ${INSTALL_NPM_VUE_CLI} = true ]; then \
|
|
npm install -g @vue/cli \
|
|
;fi \
|
|
&& if [ ${INSTALL_NPM_ANGULAR_CLI} = true ]; then \
|
|
npm install -g @angular/cli \
|
|
;fi \
|
|
&& ln -s `npm bin --global` /home/laradock/.node-bin \
|
|
;fi
|
|
|
|
# Wouldn't execute when added to the RUN statement in the above block
|
|
# Source NVM when loading bash since ~/.profile isn't loaded on non-login shell
|
|
RUN if [ ${INSTALL_NODE} = true ]; then \
|
|
echo "" >> ~/.bashrc && \
|
|
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc && \
|
|
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc \
|
|
;fi
|
|
|
|
# Add NVM binaries to root's .bashrc
|
|
USER root
|
|
|
|
RUN if [ ${INSTALL_NODE} = true ]; then \
|
|
cp -R /home/laradock/.nvm /root/ && \
|
|
chown -R root:root /root/.nvm && \
|
|
echo "" >> ~/.bashrc && \
|
|
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc && \
|
|
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc \
|
|
;fi
|
|
|
|
# Add PATH for node
|
|
ENV PATH $PATH:/home/laradock/.node-bin
|
|
|
|
# Make it so the node modules can be executed with 'docker-compose exec'
|
|
# We'll create symbolic links into '/usr/local/bin'.
|
|
RUN if [ ${INSTALL_NODE} = true ]; then \
|
|
find $NVM_DIR -type f -name node -exec ln -s {} /usr/local/bin/node \; && \
|
|
NODE_MODS_DIR="$NVM_DIR/versions/node/$(node -v)/lib/node_modules" && \
|
|
ln -s $NODE_MODS_DIR/bower/bin/bower /usr/local/bin/bower && \
|
|
ln -s $NODE_MODS_DIR/gulp/bin/gulp.js /usr/local/bin/gulp && \
|
|
ln -s $NODE_MODS_DIR/npm/bin/npm-cli.js /usr/local/bin/npm && \
|
|
ln -s $NODE_MODS_DIR/npm/bin/npx-cli.js /usr/local/bin/npx && \
|
|
ln -s $NODE_MODS_DIR/vue-cli/bin/vue /usr/local/bin/vue && \
|
|
ln -s $NODE_MODS_DIR/vue-cli/bin/vue-init /usr/local/bin/vue-init && \
|
|
ln -s $NODE_MODS_DIR/vue-cli/bin/vue-list /usr/local/bin/vue-list \
|
|
;fi
|
|
|
|
RUN if [ ${NPM_REGISTRY} ]; then \
|
|
. ~/.bashrc && npm config set registry ${NPM_REGISTRY} \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# YARN:
|
|
###########################################################################
|
|
|
|
USER laradock
|
|
|
|
ARG INSTALL_YARN=false
|
|
ARG YARN_VERSION=latest
|
|
ENV YARN_VERSION ${YARN_VERSION}
|
|
|
|
RUN if [ ${INSTALL_YARN} = true ]; then \
|
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && \
|
|
if [ ${YARN_VERSION} = "latest" ]; then \
|
|
curl -o- -L https://yarnpkg.com/install.sh | bash; \
|
|
else \
|
|
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version ${YARN_VERSION}; \
|
|
fi && \
|
|
echo "" >> ~/.bashrc && \
|
|
echo 'export PATH="$HOME/.yarn/bin:$PATH"' >> ~/.bashrc \
|
|
;fi
|
|
|
|
# Add YARN binaries to root's .bashrc
|
|
USER root
|
|
|
|
RUN if [ ${INSTALL_YARN} = true ]; then \
|
|
echo "" >> ~/.bashrc && \
|
|
echo 'export YARN_DIR="/home/laradock/.yarn"' >> ~/.bashrc && \
|
|
echo 'export PATH="$YARN_DIR/bin:$PATH"' >> ~/.bashrc \
|
|
;fi
|
|
|
|
# Add PATH for YARN
|
|
ENV PATH $PATH:/home/laradock/.yarn/bin
|
|
|
|
###########################################################################
|
|
# YARN:
|
|
###########################################################################
|
|
|
|
ARG INSTALL_GULP=false
|
|
ENV INSTALL_GULP ${INSTALL_GULP}
|
|
|
|
USER root
|
|
|
|
RUN if [ ${INSTALL_GULP} = true ]; then \
|
|
npm i -g gulp gulp-cli \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# MySQL Client:
|
|
###########################################################################
|
|
|
|
USER root
|
|
|
|
ARG INSTALL_MYSQL_CLIENT=false
|
|
|
|
RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
|
|
apt-get update -yqq && \
|
|
apt-get -y install mysql-client \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# ping:
|
|
###########################################################################
|
|
|
|
USER root
|
|
|
|
ARG INSTALL_PING=false
|
|
|
|
RUN if [ ${INSTALL_PING} = true ]; then \
|
|
apt-get update -yqq && \
|
|
apt-get -y install inetutils-ping \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# PYTHON:
|
|
###########################################################################
|
|
|
|
ARG INSTALL_PYTHON=false
|
|
|
|
RUN if [ ${INSTALL_PYTHON} = true ]; then \
|
|
apt-get -y install python python-pip python-dev build-essential \
|
|
&& python -m pip install --upgrade pip \
|
|
&& python -m pip install --upgrade virtualenv \
|
|
;fi
|
|
|
|
###########################################################################
|
|
# Check PHP version:
|
|
###########################################################################
|
|
|
|
RUN set -xe; 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
|
|
|
|
# Set default work directory
|
|
WORKDIR /var/www
|