diff --git a/Dockerfile b/Dockerfile index e900d1aea4..cbb260a711 100644 --- a/Dockerfile +++ b/Dockerfile @@ -82,8 +82,17 @@ RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ && apt-get install -y --no-install-recommends \ nodejs \ yarn \ + nano \ + vim \ + iputils-ping \ + zsh \ + telnet \ + autoconf \ + libtool \ + pkg-config \ && apt-get clean \ && rm -rf /var/lib/apt/lists \ + && git clone https://github.com/robbyrussell/oh-my-zsh.git /bootstrap/.oh-my-zsh \ && mkdir -p /var/alchemy/Phraseanet \ && chown -R app:app /var/alchemy @@ -99,10 +108,13 @@ RUN composer install --prefer-dist --no-dev --no-progress --no-suggest --classma COPY --chown=app . . -RUN rm -rf docker/phraseanet/root \ - && make install +RUN make install -ADD docker/phraseanet/ / +ADD ./docker/builder/root / + +ENTRYPOINT ["/bootstrap/entrypoint.sh"] + +CMD [] ######################################################################### # Phraseanet web application image diff --git a/README.md b/README.md index 4d9509d731..e5865b0c6b 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,20 @@ This can be made easily from the builder container: > Please note that the phraseanet image does not contain nor `composer` neither `node` tools. This allow the final image to be slim. > If you need to use dev tools, ensure you are running the `builder` image! +### Developer shell + +You can also obtain a shell access in builder container: + +```bash +docker-compose run --rm builder /bin/bash +# or +docker-compose run --rm builder /bin/zsh +``` + +In this container you will have the same libraries (PHP, Node, composer, ...) that are used to build images. +Also you have utils for development like telnet, ping, ssh, git, ... +Your $HOME/.ssh directory is also mounted to builder's home with your ssh agent. + ### Using Xdebug Xdebug is enabled by default with the `docker-compose.override.yml` diff --git a/docker-compose.override.yml b/docker-compose.override.yml index c9b846aa84..48729416e4 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -10,25 +10,29 @@ services: gateway: volumes: + - ../:/var/alchemy - .:/var/alchemy/Phraseanet - ./docker/nginx/root/entrypoint.sh:/entrypoint.sh - ${PHRASEANET_DATA_DIR}:/var/alchemy/Phraseanet/datas:rw - ${PHRASEANET_THUMBNAILS_DIR}:/var/alchemy/Phraseanet/www/thumbnails:rw - ${PHRASEANET_TMP_DIR}:/var/alchemy/Phraseanet/tmp:rw - - builder: build: context: . target: builder - command: exit 0 + stdin_open: true + tty: true volumes: + - ../:/var/alchemy - .:/var/alchemy/Phraseanet - ${PHRASEANET_CONFIG_DIR}:/var/alchemy/Phraseanet/config:rw - ${PHRASEANET_LOGS_DIR}:/var/alchemy/Phraseanet/logs:rw - ${PHRASEANET_DATA_DIR}:/var/alchemy/Phraseanet/datas:rw - ${PHRASEANET_THUMBNAILS_DIR}:/var/alchemy/Phraseanet/www/thumbnails:rw + - ${SSH_AUTH_SOCK}:/ssh-auth-sock + - ${HOME}/.ssh:/home/app/.ssh + - dev_vol:/home/app phraseanet: environment: @@ -36,6 +40,7 @@ services: - XDEBUG_CONFIG=remote_host=${XDEBUG_REMOTE_HOST} idekey=${IDE_KEY} remote_enable=1 profiler_enable=${XDEBUG_PROFILER_ENABLED} profiler_output_dir=/var/alchemy/Phraseanet/cache/profiler - PHP_IDE_CONFIG volumes: + - ../:/var/alchemy - .:/var/alchemy/Phraseanet - ${PHRASEANET_CONFIG_DIR}:/var/alchemy/Phraseanet/config:rw - ${PHRASEANET_LOGS_DIR}:/var/alchemy/Phraseanet/logs:rw @@ -45,6 +50,7 @@ services: worker: volumes: + - ../:/var/alchemy - .:/var/alchemy/Phraseanet - ${PHRASEANET_CONFIG_DIR}:/var/alchemy/Phraseanet/config:rw - ${PHRASEANET_LOGS_DIR}:/var/alchemy/Phraseanet/logs:rw @@ -77,3 +83,7 @@ networks: ipam: config: - subnet: $PHRASEANET_SUBNET_IPS + +volumes: + dev_vol: + driver: local diff --git a/docker/builder/root/bootstrap/.oh-my-zsh/themes/alchemy.zsh-theme b/docker/builder/root/bootstrap/.oh-my-zsh/themes/alchemy.zsh-theme new file mode 100644 index 0000000000..807e8b6ef7 --- /dev/null +++ b/docker/builder/root/bootstrap/.oh-my-zsh/themes/alchemy.zsh-theme @@ -0,0 +1,7 @@ +local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" +PROMPT='%* %{$fg_bold[green]%}%n%{$fg[grey]%}@%m%{$fg_bold[green]%}%u ${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' + +ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}] %{$fg[yellow]%}✗%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}]" diff --git a/docker/builder/root/bootstrap/.zshrc b/docker/builder/root/bootstrap/.zshrc new file mode 100644 index 0000000000..ae18e5a4ef --- /dev/null +++ b/docker/builder/root/bootstrap/.zshrc @@ -0,0 +1,56 @@ +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 + +export ZSH=$HOME/.oh-my-zsh + +ZSH_THEME="alchemy" + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to use hyphen-insensitive completion. Case +# sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +# Uncomment the following line to disable bi-weekly auto-update checks. +# DISABLE_AUTO_UPDATE="true" + +# Uncomment the following line to change how often to auto-update (in days). +# export UPDATE_ZSH_DAYS=13 + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +# HIST_STAMPS="mm/dd/yyyy" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=(git symfony2) + +# User configuration + +source $ZSH/oh-my-zsh.sh + +alias ll='ls -alFh' diff --git a/docker/builder/root/bootstrap/entrypoint.d/ohmyzsh.sh b/docker/builder/root/bootstrap/entrypoint.d/ohmyzsh.sh new file mode 100644 index 0000000000..aded04c7c7 --- /dev/null +++ b/docker/builder/root/bootstrap/entrypoint.d/ohmyzsh.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ ! -d "$HOME/.oh-my-zsh" ]; then + cp -r "/bootstrap/.oh-my-zsh" "$HOME/.oh-my-zsh" +fi diff --git a/docker/builder/root/bootstrap/entrypoint.d/zshrc.sh b/docker/builder/root/bootstrap/entrypoint.d/zshrc.sh new file mode 100644 index 0000000000..71d47ed475 --- /dev/null +++ b/docker/builder/root/bootstrap/entrypoint.d/zshrc.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +ZSH_FILE="$HOME/.zshrc" + +if [ ! -f "$HOME/.zshrc" ]; then + cp "/bootstrap/.zshrc" "$HOME/.zshrc" +fi diff --git a/docker/builder/root/bootstrap/entrypoint.sh b/docker/builder/root/bootstrap/entrypoint.sh new file mode 100755 index 0000000000..c8bff0d1bb --- /dev/null +++ b/docker/builder/root/bootstrap/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ -d /bootstrap/entrypoint.d ]; then + for i in /bootstrap/entrypoint.d/*.sh; do + if [ -r $i ]; then + . $i + fi + done + unset i +fi + +if [ ! -t 1 ] ; then + echo "No tty available." + exit 0 +fi + +exec "$@"