Skip to content

Commit

Permalink
Merge pull request #143 from docksal/develop
Browse files Browse the repository at this point in the history
Release 2.9.0
  • Loading branch information
lmakarov authored Oct 21, 2019
2 parents 095ca43 + 14ab7dc commit 5d0ab37
Show file tree
Hide file tree
Showing 50 changed files with 522 additions and 168 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,17 @@ install:
- fin sysinfo

script:
# Pull the latest edge image to speed up builds (hoping for image layer cache hits)
- docker pull ${REPO}:edge-php${VERSION}
# Build the base image
- cd ${TRAVIS_BUILD_DIR}/${VERSION}
- travis_retry make # Retry builds, as pecl.php.net tends to time out often
- make test
# Build the Cloud9 flavor
- cd ${TRAVIS_BUILD_DIR}/cloud9
- travis_retry make
- make test

after_success:
- docker image ls
- ${TRAVIS_BUILD_DIR}/scripts/docker-push.sh

after_failure:
- cd ${TRAVIS_BUILD_DIR}/${VERSION} && make logs
- cd ${TRAVIS_BUILD_DIR}/cloud9 && make logs
- cd ${TRAVIS_BUILD_DIR}/code-server && make logs
45 changes: 43 additions & 2 deletions 7.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.1-fpm-buster
FROM php:7.1-fpm-buster as cli

ARG DEBIAN_FRONTEND=noninteractive
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
Expand Down Expand Up @@ -231,6 +231,7 @@ RUN set -xe; \
ENV COMPOSER_VERSION=1.9.0 \
DRUSH_VERSION=8.3.0 \
DRUSH_LAUNCHER_VERSION=0.6.0 \
DRUPAL_CHECK_VERSION=1.0.13 \
DRUPAL_CONSOLE_LAUNCHER_VERSION=1.9.3 \
WPCLI_VERSION=2.3.0 \
BLACKFIRE_VERSION=1.22.0 \
Expand All @@ -250,6 +251,8 @@ RUN set -xe; \
curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \
# Platform.sh CLI
curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \
# Drupal Check CLI
curl -fsSL "https://github.com/mglaman/drupal-check/releases/download/${DRUPAL_CHECK_VERSION}/drupal-check.phar" -o /usr/local/bin/drupal-check; \
# Make all downloaded binaries executable in one shot
(cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform);

Expand Down Expand Up @@ -380,7 +383,7 @@ SHELL ["/bin/sh", "-c"]
COPY --chown=docker:docker config/.drush /home/docker/.drush
COPY --chown=docker:docker config/.terminus /home/docker/.terminus
COPY --chown=docker:docker config/.ssh /home/docker/.ssh
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/supervisor /etc/supervisor/conf.d
COPY startup.sh /opt/startup.sh
COPY healthcheck.sh /opt/healthcheck.sh
# PHP default settings, global overrides and fpm overrides
Expand All @@ -404,6 +407,7 @@ ENV \
# xdebug disabled by default
XDEBUG_ENABLED=0

# TODO: [v3] remove and set these via docker-compose
EXPOSE 9000
EXPOSE 22
EXPOSE 3000
Expand All @@ -418,3 +422,40 @@ CMD ["supervisord"]

# Health check script
HEALTHCHECK --interval=5s --timeout=1s --retries=12 CMD ["/opt/healthcheck.sh"]


# Visual Studio Code Server flavor
FROM cli as code-server

# Run as docker, so we don't have to fix permissions
USER docker

ARG HOME=/home/docker

ENV \
# TODO: 2.x versions do not yet work with xdebug
CODE_SERVER_VERSION=1.1156-vsc1.33.1 \
VSCODE_HOME="${HOME}/code-server" \
VSCODE_EXT_DIRECTORY="${HOME}/code-server/extensions" \
VSCODE_XDEBUG_VERSION=1.13.0 \
VSCODE_GITLENS_VERSION=9.9.3

# Install code-server
RUN \
set -xe; \
curl -fsSL "https://github.com/cdr/code-server/releases/download/${CODE_SERVER_VERSION}/code-server${CODE_SERVER_VERSION}-linux-x64.tar.gz" -o /tmp/code-server.tar.gz; \
tar -zxv --file=/tmp/code-server.tar.gz --directory=/tmp --strip-components=1; \
sudo mv /tmp/code-server /usr/local/bin/; rm -rf /tmp/*.*

# Settings and scripts
COPY opt/code-server /opt/code-server

# Install extensions
RUN \
set -xe; \
mkdir -p ${VSCODE_EXT_DIRECTORY}; \
/opt/code-server/install-vscode-extension https://github.com/felixfbecker/vscode-php-debug/releases/download/v${VSCODE_XDEBUG_VERSION}/php-debug.vsix felixfbecker.php-debug-${VSCODE_XDEBUG_VERSION}; \
/opt/code-server/install-vscode-extension https://github.com/eamodio/vscode-gitlens/releases/download/v${VSCODE_GITLENS_VERSION}/gitlens-${VSCODE_GITLENS_VERSION}.vsix eamodio.gitlens-${VSCODE_GITLENS_VERSION}

# Switch back to root (IMPORTANT!)
USER root
2 changes: 1 addition & 1 deletion 7.1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ VOLUMES += -v /home/docker
.PHONY: build test push shell run start stop logs clean release

build:
docker build -t $(REPO):$(TAG) .
docker build --cache-from=$(REPO):edge-php$(VERSION) -t $(REPO):$(TAG) .

test:
IMAGE=$(REPO):$(TAG) NAME=$(NAME) VERSION=$(VERSION) ../tests/test.bats
Expand Down
7 changes: 5 additions & 2 deletions 7.1/config/php/xdebug.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
; xdebug.xdebug.remote_host defaults to "localhost", which works with VS Code Server web IDE
; For debugging from the host machine, xdebug.xdebug.remote_host is set to ${DOCKSAL_HOST_IP} at runtime
; xdebug.xdebug.remote_port is set at runtime: 9000 (default)
xdebug.idekey=xdebug_session
xdebug.max_nesting_level=256
5 changes: 5 additions & 0 deletions 7.1/config/supervisor/supervisord-crond.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[program:cron]
# Cron will only log to syslog and nothing else...
command = /usr/sbin/cron -f
stdout_logfile = /var/log/supervisor/cron-stdout
stderr_logfile = /var/log/supervisor/cron-stderr
4 changes: 4 additions & 0 deletions 7.1/config/supervisor/supervisord-php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[program:php-fpm]
command = /usr/local/sbin/php-fpm
stdout_logfile = /var/log/supervisor/php-fpm-stdout
stderr_logfile = /var/log/supervisor/php-fpm-stderr
4 changes: 4 additions & 0 deletions 7.1/config/supervisor/supervisord-sshd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[program:sshd]
command = /usr/sbin/sshd -D
stdout_logfile = /var/log/supervisor/sshd-stdout
stderr_logfile = /var/log/supervisor/sshd-stderr
6 changes: 6 additions & 0 deletions 7.1/config/supervisor/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[supervisord]
nodaemon = true
# debug prints output from all services to stdout/stderr.
# This way logs can be reviewed with docker logs.
# Additionalluy, logs from specific services are forwarded to individual files on disk.
loglevel = debug
22 changes: 0 additions & 22 deletions 7.1/config/supervisord.conf

This file was deleted.

17 changes: 12 additions & 5 deletions 7.1/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/usr/bin/env bash

set -e # Exit on errors

# Initialization phase in startup.sh is complete
[[ ! -f /var/run/cli ]] && exit 1
# Need to do "|| exit 1" here since "set -e" apparently does not care about tests.
[[ -f /var/run/cli ]] || exit 1

# supervisor services are running
if [[ -f /run/supervisord.pid ]]; then
[[ ! -f /run/php-fpm.pid ]] && exit 1
[[ ! -f /run/sshd.pid ]] && exit 1
if [[ "${IDE_ENABLED}" != "1" ]]; then
# php-fpm/cli mode
[[ -f /run/php-fpm.pid ]] || exit 1
[[ -f /run/sshd.pid ]] || exit 1
else
# IDE mode
ps aux | grep code-server >/dev/null
fi
fi

exit 0
9 changes: 9 additions & 0 deletions 7.1/opt/code-server/install-vscode-extension
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

PLUGIN_URL=$1
PLUGIN_DIRECTORY=$2

curl -fsSL "${PLUGIN_URL}" -o /tmp/extension.zip
unzip -qq /tmp/extension.zip -d /tmp/extension
mv /tmp/extension/extension ${VSCODE_EXT_DIRECTORY}/${PLUGIN_DIRECTORY}
rm -rf /tmp/extension.zip /tmp/extension
26 changes: 26 additions & 0 deletions 7.1/opt/code-server/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// XDebug Launch Configuration settings
"launch": {
"version": "0.2.0",
"configurations": [
// Listener mode (recommended for most cases)
// Can be used to debug both: web and cli PHP sessions.
{
"name": "XDebug (listener)",
"type": "php",
"request": "launch",
"port": 9000
},
// Current script mode
// Note: IDE launches the script inside of the ide container and not the cli container.
{
"name": "XDebug (currently open script)",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
}
6 changes: 6 additions & 0 deletions 7.1/opt/code-server/supervisord-code-server.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# VS Code Server web IDE
[program:code-server]
# Using bash -lc here to load docker user profile (necessary for nvn/node to initialize)
command = gosu docker bash -lc '/usr/local/bin/code-server --user-data-dir=/home/docker/code-server -p 8080 /var/www --allow-http --no-auth'
stdout_logfile = /var/log/supervisor/code-server-stdout
stderr_logfile = /var/log/supervisor/code-server-stderr
14 changes: 14 additions & 0 deletions 7.1/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ xdebug_enable ()
ln -s /opt/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/
}

ide_mode_enable ()
{
echo-debug "Enabling web IDE..."
# Enabled only code-server service (disabled all other services)
# TODO: [v3] split IDE/cli and php-fpm entirely
rm -f /etc/supervisor/conf.d/supervisord-*
ln -s /opt/code-server/supervisord-code-server.conf /etc/supervisor/conf.d/
mkdir -p ${VSCODE_HOME}/User
ln -s /opt/code-server/settings.json ${VSCODE_HOME}/User/
}

# Creates symlinks to project level overrides if they exist
php_settings ()
{
Expand Down Expand Up @@ -142,6 +153,9 @@ convert_secrets
# Enable xdebug
[[ "$XDEBUG_ENABLED" != "" ]] && [[ "$XDEBUG_ENABLED" != "0" ]] && xdebug_enable

# Enable web IDE
[[ "$IDE_ENABLED" != "" ]] && [[ "$IDE_ENABLED" != "0" ]] && ide_mode_enable

# Include project level PHP settings if found
php_settings

Expand Down
45 changes: 43 additions & 2 deletions 7.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.2-fpm-buster
FROM php:7.2-fpm-buster as cli

ARG DEBIAN_FRONTEND=noninteractive
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
Expand Down Expand Up @@ -229,6 +229,7 @@ RUN set -xe; \
ENV COMPOSER_VERSION=1.9.0 \
DRUSH_VERSION=8.3.0 \
DRUSH_LAUNCHER_VERSION=0.6.0 \
DRUPAL_CHECK_VERSION=1.0.13 \
DRUPAL_CONSOLE_LAUNCHER_VERSION=1.9.3 \
WPCLI_VERSION=2.3.0 \
BLACKFIRE_VERSION=1.22.0 \
Expand All @@ -248,6 +249,8 @@ RUN set -xe; \
curl -fsSL "https://packages.blackfire.io/binaries/blackfire-agent/${BLACKFIRE_VERSION}/blackfire-cli-linux_static_amd64" -o /usr/local/bin/blackfire; \
# Platform.sh CLI
curl -fsSL "https://github.com/platformsh/platformsh-cli/releases/download/v${PLATFORMSH_CLI_VERSION}/platform.phar" -o /usr/local/bin/platform; \
# Drupal Check CLI
curl -fsSL "https://github.com/mglaman/drupal-check/releases/download/${DRUPAL_CHECK_VERSION}/drupal-check.phar" -o /usr/local/bin/drupal-check; \
# Make all downloaded binaries executable in one shot
(cd /usr/local/bin && chmod +x composer drush8 drush drupal wp blackfire platform);

Expand Down Expand Up @@ -378,7 +381,7 @@ SHELL ["/bin/sh", "-c"]
COPY --chown=docker:docker config/.drush /home/docker/.drush
COPY --chown=docker:docker config/.terminus /home/docker/.terminus
COPY --chown=docker:docker config/.ssh /home/docker/.ssh
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/supervisor /etc/supervisor/conf.d
COPY startup.sh /opt/startup.sh
COPY healthcheck.sh /opt/healthcheck.sh
# PHP default settings, global overrides and fpm overrides
Expand All @@ -402,6 +405,7 @@ ENV \
# xdebug disabled by default
XDEBUG_ENABLED=0

# TODO: [v3] remove and set these via docker-compose
EXPOSE 9000
EXPOSE 22
EXPOSE 3000
Expand All @@ -416,3 +420,40 @@ CMD ["supervisord"]

# Health check script
HEALTHCHECK --interval=5s --timeout=1s --retries=12 CMD ["/opt/healthcheck.sh"]


# Visual Studio Code Server flavor
FROM cli as code-server

# Run as docker, so we don't have to fix permissions
USER docker

ARG HOME=/home/docker

ENV \
# TODO: 2.x versions do not yet work with xdebug
CODE_SERVER_VERSION=1.1156-vsc1.33.1 \
VSCODE_HOME="${HOME}/code-server" \
VSCODE_EXT_DIRECTORY="${HOME}/code-server/extensions" \
VSCODE_XDEBUG_VERSION=1.13.0 \
VSCODE_GITLENS_VERSION=9.9.3

# Install code-server
RUN \
set -xe; \
curl -fsSL "https://github.com/cdr/code-server/releases/download/${CODE_SERVER_VERSION}/code-server${CODE_SERVER_VERSION}-linux-x64.tar.gz" -o /tmp/code-server.tar.gz; \
tar -zxv --file=/tmp/code-server.tar.gz --directory=/tmp --strip-components=1; \
sudo mv /tmp/code-server /usr/local/bin/; rm -rf /tmp/*.*

# Settings and scripts
COPY opt/code-server /opt/code-server

# Install extensions
RUN \
set -xe; \
mkdir -p ${VSCODE_EXT_DIRECTORY}; \
/opt/code-server/install-vscode-extension https://github.com/felixfbecker/vscode-php-debug/releases/download/v${VSCODE_XDEBUG_VERSION}/php-debug.vsix felixfbecker.php-debug-${VSCODE_XDEBUG_VERSION}; \
/opt/code-server/install-vscode-extension https://github.com/eamodio/vscode-gitlens/releases/download/v${VSCODE_GITLENS_VERSION}/gitlens-${VSCODE_GITLENS_VERSION}.vsix eamodio.gitlens-${VSCODE_GITLENS_VERSION}

# Switch back to root (IMPORTANT!)
USER root
2 changes: 1 addition & 1 deletion 7.2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ VOLUMES += -v /home/docker
.PHONY: build test push shell run start stop logs clean release

build:
docker build -t $(REPO):$(TAG) .
docker build --cache-from=$(REPO):edge-php$(VERSION) -t $(REPO):$(TAG) .

test:
IMAGE=$(REPO):$(TAG) NAME=$(NAME) VERSION=$(VERSION) ../tests/test.bats
Expand Down
7 changes: 5 additions & 2 deletions 7.2/config/php/xdebug.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
; xdebug.xdebug.remote_host defaults to "localhost", which works with VS Code Server web IDE
; For debugging from the host machine, xdebug.xdebug.remote_host is set to ${DOCKSAL_HOST_IP} at runtime
; xdebug.xdebug.remote_port is set at runtime: 9000 (default)
xdebug.idekey=xdebug_session
xdebug.max_nesting_level=256
5 changes: 5 additions & 0 deletions 7.2/config/supervisor/supervisord-crond.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[program:cron]
# Cron will only log to syslog and nothing else...
command = /usr/sbin/cron -f
stdout_logfile = /var/log/supervisor/cron-stdout
stderr_logfile = /var/log/supervisor/cron-stderr
4 changes: 4 additions & 0 deletions 7.2/config/supervisor/supervisord-php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[program:php-fpm]
command = /usr/local/sbin/php-fpm
stdout_logfile = /var/log/supervisor/php-fpm-stdout
stderr_logfile = /var/log/supervisor/php-fpm-stderr
4 changes: 4 additions & 0 deletions 7.2/config/supervisor/supervisord-sshd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[program:sshd]
command = /usr/sbin/sshd -D
stdout_logfile = /var/log/supervisor/sshd-stdout
stderr_logfile = /var/log/supervisor/sshd-stderr
6 changes: 6 additions & 0 deletions 7.2/config/supervisor/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[supervisord]
nodaemon = true
# debug prints output from all services to stdout/stderr.
# This way logs can be reviewed with docker logs.
# Additionalluy, logs from specific services are forwarded to individual files on disk.
loglevel = debug
Loading

0 comments on commit 5d0ab37

Please sign in to comment.