Browse Source

* workspace base with minio

master
dimti 4 years ago
parent
commit
cd422e4e6b
  1. 22
      .env.example
  2. 27
      docker-compose.base.yml
  3. 2
      docker-compose.elastic.base.yml
  4. 16
      docker-compose.minio.base.yml
  5. 10
      docker-compose.minio.yml
  6. 20
      docker-compose.yml.example
  7. 2
      dockerfiles/php-fpm/php.base.Dockerfile
  8. 5
      dockerfiles/php-fpm/php73.Dockerfile
  9. 5
      dockerfiles/php-fpm/php74.Dockerfile
  10. 0
      dockerfiles/workspace/aliases.sh
  11. 0
      dockerfiles/workspace/composer.json
  12. 0
      dockerfiles/workspace/crontab/laradock
  13. 12
      dockerfiles/workspace/minio/auth.json
  14. 249
      dockerfiles/workspace/workspace.base.Dockerfile
  15. 6
      dockerfiles/workspace/workspace73.Dockerfile
  16. 6
      dockerfiles/workspace/workspace74.Dockerfile
  17. 0
      dockerfiles/workspace/xdebug.ini
  18. 0
      dockerfiles/workspace/xdebug.sh
  19. 11
      dockerfiles/workspace73/auth.json
  20. 475
      dockerfiles/workspace74/Dockerfile
  21. 153
      dockerfiles/workspace74/aliases.sh
  22. 11
      dockerfiles/workspace74/auth.json
  23. 5
      dockerfiles/workspace74/composer.json
  24. 1
      dockerfiles/workspace74/crontab/laradock
  25. 20
      dockerfiles/workspace74/xdebug.ini
  26. 101
      dockerfiles/workspace74/xdebug.sh

22
.env.example

@ -3,29 +3,27 @@ DOCKER_HOST_IP=172.20.0.1
PROJECTS_DIR=/home/youruser/PhpstormProjects
### WORKSPACE #############################################
WORKSPACE_PHP_VERSION=7.3
WORKSPACE_PUID=1000
WORKSPACE_PGID=1000
WORKSPACE_TIMEZONE=Europe/Moscow
WORKSPACE_INSTALL_SSH=true
WORKSPACE_INSTALL_MYSQL_CLIENT=true
WORKSPACE_INSTALL_PYTHON=true
WORKSPACE_INSTALL_FSWATCH=false
WORKSPACE_INSTALL_PING=true
WORKSPACE_INSTALL_S3_MINIO_CLIENT=true
WORKSPACE_COMPOSER_VERSION=1
WORKSPACE_COMPOSER_GLOBAL_INSTALL=true
WORKSPACE_COMPOSER_AUTH=false
WORKSPACE_COMPOSER_REPO_PACKAGIST=
WORKSPACE_INSTALL_WP_CLI=true
WORKSPACE_INSTALL_XDEBUG=false
WORKSPACE_INSTALL_SSH=true
WORKSPACE_SSH_PASSPHRAZE=
WORKSPACE_INSTALL_FSWATCH=false
WORKSPACE_INSTALL_WP_CLI=true
WORKSPACE_INSTALL_NODE=true
WORKSPACE_NODE_VERSION=lts/dubnium
WORKSPACE_NPM_REGISTRY=
WORKSPACE_INSTALL_GULP=true
WORKSPACE_INSTALL_YARN=true
WORKSPACE_YARN_VERSION=latest
WORKSPACE_INSTALL_GULP=true
WORKSPACE_INSTALL_MYSQL_CLIENT=true
WORKSPACE_INSTALL_PING=true
WORKSPACE_INSTALL_PYTHON=true
WORKSPACE_INSTALL_S3_MINIO_CLIENT=true
### PHP-FPM #############################################
INSTALL_XDEBUG=true
@ -40,3 +38,7 @@ PHP_OPT_SHORT_OPEN_TAG=On
PHP_OPT_MAX_EXECUTION_TIME=600
PHP_OPT_MEMORY_LIMIT=500M
PHP_OPT_UPLOAD_MAX_FILESIZE=20M
### MINIO S3 #############################################
MINIO_ACCESS_KEY=s3.local
MINIO_SECRET_KEY=qbKTLqAumjYOYlCXCRk6

27
docker-compose.base.yml

@ -18,7 +18,6 @@ services:
- "443:443"
expose:
- 80
php-fpm:
build:
context: ./dockerfiles/php-fpm
@ -40,38 +39,35 @@ services:
- ${PROJECTS_DIR}:/usr/share/nginx/html
expose:
- 9000
workspace:
build:
context: ./dockerfiles/workspace
args:
- PHP_VERSION=${WORKSPACE_PHP_VERSION}
- PUID=${WORKSPACE_PUID}
- PGID=${WORKSPACE_PGID}
- TZ=${WORKSPACE_TIMEZONE}
- INSTALL_SSH=${WORKSPACE_INSTALL_SSH}
- INSTALL_MYSQL_CLIENT=${WORKSPACE_INSTALL_MYSQL_CLIENT}
- INSTALL_PYTHON=${WORKSPACE_INSTALL_PYTHON}
- INSTALL_FSWATCH=${WORKSPACE_INSTALL_FSWATCH}
- INSTALL_PING=${WORKSPACE_INSTALL_PING}
- INSTALL_S3_MINIO_CLIENT=${WORKSPACE_INSTALL_S3_MINIO_CLIENT}
- COMPOSER_VERSION=${WORKSPACE_COMPOSER_VERSION}
- COMPOSER_GLOBAL_INSTALL=${WORKSPACE_COMPOSER_GLOBAL_INSTALL}
- COMPOSER_AUTH=${WORKSPACE_COMPOSER_AUTH}
- COMPOSER_REPO_PACKAGIST=${WORKSPACE_COMPOSER_REPO_PACKAGIST}
- INSTALL_WP_CLI=${WORKSPACE_INSTALL_WP_CLI}
- INSTALL_XDEBUG=${WORKSPACE_INSTALL_XDEBUG}
- INSTALL_SSH=${WORKSPACE_INSTALL_SSH}
- SSH_PASSPHRAZE=${WORKSPACE_SSH_PASSPHRAZE}
- INSTALL_FSWATCH=${WORKSPACE_INSTALL_FSWATCH}
- INSTALL_WP_CLI=${WORKSPACE_INSTALL_WP_CLI}
- INSTALL_NODE=${WORKSPACE_INSTALL_NODE}
- NODE_VERSION=${WORKSPACE_NODE_VERSION}
- NPM_REGISTRY=${WORKSPACE_NPM_REGISTRY}
- INSTALL_GULP=${WORKSPACE_INSTALL_GULP}
- INSTALL_YARN=${WORKSPACE_INSTALL_YARN}
- YARN_VERSION=${WORKSPACE_YARN_VERSION}
- INSTALL_GULP=${WORKSPACE_INSTALL_GULP}
- INSTALL_MYSQL_CLIENT=${WORKSPACE_INSTALL_MYSQL_CLIENT}
- INSTALL_PING=${WORKSPACE_INSTALL_PING}
- INSTALL_PYTHON=${WORKSPACE_INSTALL_PYTHON}
restart: always
volumes:
- ${PROJECTS_DIR}:/var/www
extra_hosts:
- "dockerhost:${DOCKER_HOST_IP}"
db:
image: mariadb
restart: always
@ -82,7 +78,6 @@ services:
- ./hostfiles:/hostfiles
ports:
- "3306:3306"
pma:
image: phpmyadmin/phpmyadmin
restart: always
@ -92,7 +87,6 @@ services:
PMA_PASSWORD: 123456
ports:
- "81:80"
redis:
image: redis
restart: always
@ -100,3 +94,6 @@ services:
volumes:
- ./config/redis/redis.conf:/usr/local/etc/redis/redis.conf
# Must be copied into main docker-compose yml-file
volumes:
database:

2
docker-compose.elastic.base.yml

@ -19,6 +19,6 @@ services:
- "9200"
- "9300"
# Must be copied into main docker-compose yml-file
# Must be copied into main elastic docker-compose yml-file
volumes:
elastic:

16
docker-compose.minio.base.yml

@ -0,0 +1,16 @@
version: '3.6'
services:
minio:
image: minio/minio:RELEASE.2020-06-12T00-06-19Z
restart: always
volumes:
- minio:/minio
environment:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
command: server /minio
# Must be copied into main minio docker-compose yml-file
volumes:
minio:

10
docker-compose.minio.yml

@ -0,0 +1,10 @@
version: '3.6'
services:
minio:
extends:
file: docker-compose.minio.base.yml
service: minio
volumes:
minio:

20
docker-compose.yml.example

@ -5,60 +5,42 @@ services:
extends:
file: docker-compose.base.yml
service: nginx
php73:
extends:
file: docker-compose.base.yml
service: php-fpm
build:
dockerfile: php73.Dockerfile
php74:
extends:
file: docker-compose.base.yml
service: php-fpm
build:
dockerfile: php74.Dockerfile
workspace73:
extends:
file: docker-compose.base.yml
service: workspace
build:
context: ./dockerfiles/workspace73
workspace74:
extends:
file: docker-compose.base.yml
service: workspace
build:
context: ./dockerfiles/workspace74
db:
extends:
file: docker-compose.base.yml
service: db
pma:
extends:
file: docker-compose.base.yml
service: pma
redis:
extends:
file: docker-compose.base.yml
service: redis
redis-salvoterra:
extends:
file: docker-compose.base.yml
service: redis
restart: on-failure
redis-allislam:
extends:
file: docker-compose.base.yml
service: redis
volumes:
database:
database:

2
dockerfiles/php-fpm/php.base.Dockerfile

@ -4,8 +4,6 @@ RUN apt-get update && apt-get install -y \
libpng-dev \
libwebp-dev \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install mysqli \
&& docker-php-ext-enable mysqli

5
dockerfiles/php-fpm/php73.Dockerfile

@ -1,4 +1,7 @@
# syntax = edrevo/dockerfile-plus
FROM php:7.3-fpm
INCLUDE+ ./php.base.Dockerfile
INCLUDE+ ./php.base.Dockerfile
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd

5
dockerfiles/php-fpm/php74.Dockerfile

@ -1,4 +1,7 @@
# syntax = edrevo/dockerfile-plus
FROM php:7.4-fpm
INCLUDE+ ./php.base.Dockerfile
INCLUDE+ ./php.base.Dockerfile
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install -j$(nproc) gd

0
dockerfiles/workspace73/aliases.sh → dockerfiles/workspace/aliases.sh

0
dockerfiles/workspace73/composer.json → dockerfiles/workspace/composer.json

0
dockerfiles/workspace73/crontab/laradock → dockerfiles/workspace/crontab/laradock

12
dockerfiles/workspace/minio/auth.json

@ -0,0 +1,12 @@
{
"version": "10",
"aliases": {
"local": {
"url": "http://minio:9000",
"accessKey": "s3.local",
"secretKey": "qbKTLqAumjYOYlCXCRk6",
"api": "S3v4",
"path": "auto"
}
}
}

249
dockerfiles/workspace73/Dockerfile → dockerfiles/workspace/workspace.base.Dockerfile

@ -11,13 +11,7 @@
#
# 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="WP Studio <info@wpstudio.ru>"
LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"
# Set Environment Variables
ENV DEBIAN_FRONTEND noninteractive
@ -108,6 +102,25 @@ RUN echo "" >> ~/.bashrc && \
echo "" >> ~/.bashrc
###########################################################################
# ssh:
###########################################################################
USER root
ARG INSTALL_SSH=false
ENV INSTALL_SSH ${INSTALL_SSH}
RUN if [ ${INSTALL_SSH} = true ]; then \
rm -f /etc/service/sshd/down \
;fi
USER laradock
RUN if [ ${INSTALL_SSH} = true ]; then \
mkdir -p ~/.ssh && ln -s /run/secrets/user_ssh_key ~/.ssh/id_rsa \
;fi
###########################################################################
# MySQL Client:
###########################################################################
@ -121,6 +134,61 @@ RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
;fi
###########################################################################
# PYTHON:
###########################################################################
USER root
ARG INSTALL_PYTHON=false
RUN if [ ${INSTALL_PYTHON} = true ]; then \
apt-get update && apt-get -y install python python-pip python-dev build-essential \
&& python -m pip install --upgrade "pip < 21.0" \
&& python -m pip install --upgrade virtualenv \
;fi
###########################################################################
# fswatch
###########################################################################
USER root
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
###########################################################################
# ping:
###########################################################################
USER root
ARG INSTALL_PING=false
RUN if [ ${INSTALL_PING} = true ]; then \
apt-get update -yqq && \
apt-get -y install inetutils-ping \
;fi
###########################################################################
# Install S3 minio client:
###########################################################################
USER root
ARG INSTALL_S3_MINIO_CLIENT=false
RUN if [ ${INSTALL_S3_MINIO_CLIENT} = true ]; then \
curl https://dl.min.io/client/mc/release/linux-amd64/mc > /usr/local/sbin/mc \
&& chmod +x /usr/local/sbin/mc \
; fi
###########################################################################
# Composer:
###########################################################################
@ -129,12 +197,11 @@ 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
RUN ln -s /run/secrets/composer_auth /home/laradock/.composer/auth.json
# Export composer vendor path
RUN echo "" >> ~/.bashrc && \
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
@ -155,15 +222,6 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \
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}
@ -192,69 +250,6 @@ RUN echo "" >> ~/.bashrc && \
RUN set -xe; php -v | head -n 1 | grep -q "PHP ${PHP_VERSION}."
###########################################################################
# 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 < 21.0" \
&& python -m pip install --upgrade virtualenv \
;fi
###########################################################################
# 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:
###########################################################################
@ -276,56 +271,29 @@ RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${P
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:
# WP CLI:
###########################################################################
USER root
RUN pecl install igbinary \
&& pecl install -a redis
###########################################################################
# ssh:
###########################################################################
# The command line interface for WordPress
USER root
ARG INSTALL_SSH=false
ENV INSTALL_SSH ${INSTALL_SSH}
ARG SSH_PASSPHRAZE=
ENV SSH_PASSPHRAZE ${SSH_PASSPHRAZE}
RUN ssh-keygen -f /tmp/id_rsa -N '${SSH_PASSPHRAZE}'
ARG INSTALL_WP_CLI=false
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 \
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
###########################################################################
# fswatch
# Additional PHP-extensions:
###########################################################################
USER root
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
RUN pecl install igbinary \
&& pecl install -a redis
###########################################################################
# Node / NVM:
@ -413,12 +381,26 @@ RUN if [ ${NPM_REGISTRY} ]; then \
;fi
###########################################################################
# GULP:
###########################################################################
ARG INSTALL_GULP=false
ENV INSTALL_GULP ${INSTALL_GULP}
USER root
RUN if [ ${INSTALL_GULP} = true ]; then \
npm i -g gulp gulp-cli \
;fi
###########################################################################
# YARN:
###########################################################################
USER laradock
ARG INSTALL_YARN=false
ENV INSTALL_YARN ${INSTALL_YARN}
ARG YARN_VERSION=latest
ENV YARN_VERSION ${YARN_VERSION}
@ -446,18 +428,37 @@ RUN if [ ${INSTALL_YARN} = true ]; then \
ENV PATH $PATH:/home/laradock/.yarn/bin
###########################################################################
# GULP:
# S3 config helper
###########################################################################
ARG INSTALL_GULP=false
ENV INSTALL_GULP ${INSTALL_GULP}
USER laradock
USER root
COPY ./minio/auth.json /home/laradock/.mc/config.json
RUN if [ ${INSTALL_GULP} = true ]; then \
npm i -g gulp gulp-cli \
###########################################################################
# Add known hosts
###########################################################################
USER laradock
RUN if [ ${INSTALL_SSH} = true ]; then \
mkdir -p ~/.ssh && ln -s /run/secrets/user_ssh_key ~/.ssh/id_rsa \
&& ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts \
&& ssh-keyscan -t rsa bitbucket.org >> ~/.ssh/known_hosts \
&& ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts \
&& ssh-keyscan -t rsa vcs.wpstudio.ru >> ~/.ssh/known_hosts \
;fi
###########################################################################
# Crontab
###########################################################################
USER root
COPY ./crontab /etc/cron.d
RUN chmod -R 644 /etc/cron.d
#
#--------------------------------------------------------------------------
# Final Touch

6
dockerfiles/workspace/workspace73.Dockerfile

@ -0,0 +1,6 @@
# syntax = edrevo/dockerfile-plus
ARG PHP_VERSION=7.3
FROM laradock/workspace:latest-${PHP_VERSION}
INCLUDE+ ./workspace.base.Dockerfile

6
dockerfiles/workspace/workspace74.Dockerfile

@ -0,0 +1,6 @@
# syntax = edrevo/dockerfile-plus
ARG PHP_VERSION=7.4
FROM laradock/workspace:latest-${PHP_VERSION}
INCLUDE+ ./workspace.base.Dockerfile

0
dockerfiles/workspace73/xdebug.ini → dockerfiles/workspace/xdebug.ini

0
dockerfiles/workspace73/xdebug.sh → dockerfiles/workspace/xdebug.sh

11
dockerfiles/workspace73/auth.json

@ -1,11 +0,0 @@
{
"http-basic": {
"repo.magento.com": {
"username": "",
"password": ""
}
},
"github-oauth": {
"github.com": "e12b92ef777d9cfdd43c95a557dce7ffe4ad4407"
}
}

475
dockerfiles/workspace74/Dockerfile

@ -1,475 +0,0 @@
#
#--------------------------------------------------------------------------
# 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="WP Studio <info@wpstudio.ru>"
# 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
###########################################################################
# 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
###########################################################################
# 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
# 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 composer self-update --${COMPOSER_VERSION}
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
###########################################################################
# Check PHP version:
###########################################################################
RUN set -xe; php -v | head -n 1 | grep -q "PHP ${PHP_VERSION}."
###########################################################################
# 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 < 21.0" \
&& python -m pip install --upgrade virtualenv \
;fi
###########################################################################
# 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:
###########################################################################
USER root
RUN pecl install igbinary \
&& pecl install -a redis
###########################################################################
# ssh:
###########################################################################
USER root
ARG INSTALL_SSH=false
ENV INSTALL_SSH ${INSTALL_SSH}
ARG SSH_PASSPHRAZE=
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
###########################################################################
USER root
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
###########################################################################
# GULP:
###########################################################################
ARG INSTALL_GULP=false
ENV INSTALL_GULP ${INSTALL_GULP}
USER root
RUN if [ ${INSTALL_GULP} = true ]; then \
npm i -g gulp gulp-cli \
;fi
#
#--------------------------------------------------------------------------
# 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

153
dockerfiles/workspace74/aliases.sh

@ -1,153 +0,0 @@
#! /bin/bash
# Colors used for status updates
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
COL_YELLOW=$ESC_SEQ"33;01m"
COL_BLUE=$ESC_SEQ"34;01m"
COL_MAGENTA=$ESC_SEQ"35;01m"
COL_CYAN=$ESC_SEQ"36;01m"
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
else # macOS `ls`
colorflag="-G"
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
fi
# List all files colorized in long format
#alias l="ls -lF ${colorflag}"
### MEGA: I want l and la ti return hisdden files
alias l="ls -laF ${colorflag}"
# List all files colorized in long format, including dot files
alias la="ls -laF ${colorflag}"
# List only directories
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
# Commonly Used Aliases
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
alias home="cd ~"
alias h="history"
alias j="jobs"
alias e='exit'
alias c="clear"
alias cla="clear && ls -la"
alias cll="clear && ls -l"
alias cls="clear && ls"
alias code="cd /var/www"
alias ea="vi ~/aliases.sh"
# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias art="php artisan"
alias artisan="php artisan"
alias cdump="composer dump-autoload -o"
alias composer:dump="composer dump-autoload -o"
alias db:reset="php artisan migrate:reset && php artisan migrate --seed"
alias dusk="php artisan dusk"
alias fresh="php artisan migrate:fresh"
alias migrate="php artisan migrate"
alias refresh="php artisan migrate:refresh"
alias rollback="php artisan migrate:rollback"
alias seed="php artisan db:seed"
alias serve="php artisan serve --quiet &"
alias phpunit="./vendor/bin/phpunit"
alias pu="phpunit"
alias puf="phpunit --filter"
alias pud='phpunit --debug'
alias cc='codecept'
alias ccb='codecept build'
alias ccr='codecept run'
alias ccu='codecept run unit'
alias ccf='codecept run functional'
alias g="gulp"
alias npm-global="npm list -g --depth 0"
alias ra="reload"
alias reload="source ~/.aliases && echo \"$COL_GREEN ==> Aliases Reloaded... $COL_RESET \n \""
alias run="npm run"
alias tree="xtree"
# Xvfb
alias xvfb="Xvfb -ac :0 -screen 0 1024x768x16 &"
# requires installation of 'https://www.npmjs.com/package/npms-cli'
alias npms="npms search"
# requires installation of 'https://www.npmjs.com/package/package-menu-cli'
alias pm="package-menu"
# requires installation of 'https://www.npmjs.com/package/pkg-version-cli'
alias pv="package-version"
# requires installation of 'https://github.com/sindresorhus/latest-version-cli'
alias lv="latest-version"
# git aliases
alias gaa="git add ."
alias gd="git --no-pager diff"
alias git-revert="git reset --hard && git clean -df"
alias gs="git status"
alias whoops="git reset --hard && git clean -df"
alias glog="git log --oneline --decorate --graph"
alias gloga="git log --oneline --decorate --graph --all"
alias gsh="git show"
alias grb="git rebase -i"
alias gbr="git branch"
alias gc="git commit"
alias gck="git checkout"
alias gull="git pull --rebase"
alias gush="git push"
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$@"
}
function md() {
mkdir -p "$@" && cd "$@"
}
function xtree {
find ${1:-.} -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
}
# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
# the `.git` directory, listing directories first. The output gets piped into
# `less` with options to preserve color and line numbers, unless the output is
# small enough for one screen.
function tre() {
tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh;
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
du $arg -- "$@";
else
du $arg .[^.]* ./*;
fi;
}

11
dockerfiles/workspace74/auth.json

@ -1,11 +0,0 @@
{
"http-basic": {
"repo.magento.com": {
"username": "",
"password": ""
}
},
"github-oauth": {
"github.com": "e12b92ef777d9cfdd43c95a557dce7ffe4ad4407"
}
}

5
dockerfiles/workspace74/composer.json

@ -1,5 +0,0 @@
{
"require": {
}
}

1
dockerfiles/workspace74/crontab/laradock

@ -1 +0,0 @@
* * * * * laradock /usr/bin/php /var/www/artisan schedule:run >> /dev/null 2>&1

20
dockerfiles/workspace74/xdebug.ini

@ -1,20 +0,0 @@
; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)
xdebug.remote_host=dockerhost
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

101
dockerfiles/workspace74/xdebug.sh

@ -1,101 +0,0 @@
#! /bin/bash
# NOTE: At the moment, this has only been confirmed to work with PHP 7
# Grab full name of workspace container
WORKSPACE_CONTAINER=$(docker ps | grep workspace | awk '{print $1}')
# Grab OS type
if [[ "$(uname)" == "Darwin" ]]; then
OS_TYPE="OSX"
else
OS_TYPE=$(expr substr $(uname -s) 1 5)
fi
xdebug_status ()
{
echo 'xDebug status'
# If running on Windows, need to prepend with winpty :(
if [[ $OS_TYPE == "MINGW" ]]; then
winpty docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
else
docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
fi
}
xdebug_start ()
{
echo 'Start xDebug'
# And uncomment line with xdebug extension, thus enabling it
ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' \
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
# If running on Windows, need to prepend with winpty :(
if [[ $OS_TYPE == "MINGW" ]]; then
winpty docker exec -it $WORKSPACE_CONTAINER bash -c "${ON_CMD}"
docker restart $WORKSPACE_CONTAINER
winpty docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
else
docker exec -it $WORKSPACE_CONTAINER bash -c "${ON_CMD}"
docker restart $WORKSPACE_CONTAINER
docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
fi
}
xdebug_stop ()
{
echo 'Stop xDebug'
# Comment out xdebug extension line
OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
# If running on Windows, need to prepend with winpty :(
if [[ $OS_TYPE == "MINGW" ]]; then
# This is the equivalent of:
# winpty docker exec -it laradock_php-fpm_1 bash -c 'bla bla bla'
# Thanks to @michaelarnauts at https://github.com/docker/compose/issues/593
winpty docker exec -it $WORKSPACE_CONTAINER bash -c "${OFF_CMD}"
docker restart $WORKSPACE_CONTAINER
#docker-compose restart php-fpm
winpty docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
else
docker exec -it $WORKSPACE_CONTAINER bash -c "${OFF_CMD}"
# docker-compose restart php-fpm
docker restart $WORKSPACE_CONTAINER
docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
fi
}
case $@ in
stop|STOP)
xdebug_stop
;;
start|START)
xdebug_start
;;
status|STATUS)
xdebug_status
;;
*)
echo "xDebug [Stop | Start | Status] in the ${WORKSPACE_CONTAINER} container."
echo "xDebug must have already been installed."
echo "Usage:"
echo " .php-fpm/xdebug stop|start|status"
esac
exit 1
Loading…
Cancel
Save