mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
add install-plugin script,
add project name env
This commit is contained in:
5
.env
5
.env
@@ -1,3 +1,4 @@
|
|||||||
|
PHRASEANET_PROJECT_NAME=Phraseanet
|
||||||
# Registry from where you pull Docker images
|
# Registry from where you pull Docker images
|
||||||
PHRASEANET_DOCKER_REGISTRY=local
|
PHRASEANET_DOCKER_REGISTRY=local
|
||||||
# Tag of the Docker images
|
# Tag of the Docker images
|
||||||
@@ -70,3 +71,7 @@ PHRASEANET_DB_DIR=./volumes/db
|
|||||||
PHRASEANET_ELASTICSEARCH_DIR=./volumes/elasticsearch
|
PHRASEANET_ELASTICSEARCH_DIR=./volumes/elasticsearch
|
||||||
PHRASEANET_THUMBNAILS_DIR=./www/thumbnails
|
PHRASEANET_THUMBNAILS_DIR=./www/thumbnails
|
||||||
PHRASEANET_TMP_DIR=./tmp
|
PHRASEANET_TMP_DIR=./tmp
|
||||||
|
|
||||||
|
# Plugin support
|
||||||
|
PHRASEANET_PLUGINS=
|
||||||
|
PHRASEANET_SSH_PRIVATE_KEY=
|
||||||
|
16
Dockerfile
16
Dockerfile
@@ -86,6 +86,7 @@ RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
|
|||||||
vim \
|
vim \
|
||||||
iputils-ping \
|
iputils-ping \
|
||||||
zsh \
|
zsh \
|
||||||
|
ssh \
|
||||||
telnet \
|
telnet \
|
||||||
autoconf \
|
autoconf \
|
||||||
libtool \
|
libtool \
|
||||||
@@ -112,6 +113,21 @@ RUN make install
|
|||||||
|
|
||||||
ADD ./docker/builder/root /
|
ADD ./docker/builder/root /
|
||||||
|
|
||||||
|
# SSH Private repo
|
||||||
|
ARG SSH_PRIVATE_KEY
|
||||||
|
ARG PHRASEANET_PLUGINS
|
||||||
|
|
||||||
|
RUN ( \
|
||||||
|
test ! -z "${SSH_PRIVATE_KEY}" \
|
||||||
|
&& mkdir -p ~/.ssh \
|
||||||
|
&& echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa \
|
||||||
|
# make sure github domain.com is accepted
|
||||||
|
&& ssh-keyscan -H github.com >> ~/.ssh/known_hosts \
|
||||||
|
&& chmod 600 ~/.ssh/id_rsa \
|
||||||
|
) || echo "Skip SSH key"
|
||||||
|
|
||||||
|
RUN ./docker/phraseanet/install-plugins
|
||||||
|
|
||||||
ENTRYPOINT ["/bootstrap/entrypoint.sh"]
|
ENTRYPOINT ["/bootstrap/entrypoint.sh"]
|
||||||
|
|
||||||
CMD []
|
CMD []
|
||||||
|
22
README.md
22
README.md
@@ -146,6 +146,28 @@ XDEBUG_REMOTE_HOST=host.docker.internal
|
|||||||
|
|
||||||
> Don't forget to recreate your container (`docker-compose up -d phraseanet`)
|
> Don't forget to recreate your container (`docker-compose up -d phraseanet`)
|
||||||
|
|
||||||
|
### Build images with plugins
|
||||||
|
|
||||||
|
Plugins can be installed during build if you set the `PHRASEANET_PLUGINS` env var as follows:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PHRASEANET_PLUGINS="git@github.com:alchemy-fr/Phraseanet-plugin-webgallery.git"
|
||||||
|
|
||||||
|
# You can optionally precise the branch to install
|
||||||
|
# If not precised, the main branch will be pulled
|
||||||
|
PHRASEANET_PLUGINS="git@github.com:alchemy-fr/Phraseanet-plugin-webgallery.git(custom-branch)"
|
||||||
|
|
||||||
|
# Plugins are separated by spaces
|
||||||
|
PHRASEANET_PLUGINS="git@github.com:foo/bar.git(branch-1) git@github.com:baz/42.git"
|
||||||
|
```
|
||||||
|
|
||||||
|
If you install private plugins, make sure you export your SSH private key content in order to allow docker build to access the GIT repository:
|
||||||
|
```bash
|
||||||
|
export PHRASEANET_SSH_PRIVATE_KEY=$(cat ~/.ssh/id_rsa)
|
||||||
|
# or if your private key is protected by a passphrase:
|
||||||
|
export PHRASEANET_SSH_PRIVATE_KEY=$(openssl rsa -in ~/.ssh/id_rsa -out /tmp/id_rsa_raw && cat /tmp/id_rsa_raw && rm /tmp/id_rsa_raw)
|
||||||
|
```
|
||||||
|
|
||||||
# With Vagrant (deprecated)
|
# With Vagrant (deprecated)
|
||||||
|
|
||||||
## Development :
|
## Development :
|
||||||
|
@@ -21,6 +21,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
target: builder
|
target: builder
|
||||||
|
args:
|
||||||
|
- SSH_PRIVATE_KEY=${PHRASEANET_SSH_PRIVATE_KEY}
|
||||||
|
- PHRASEANET_PLUGINS=${PHRASEANET_PLUGINS}
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
volumes:
|
volumes:
|
||||||
@@ -33,6 +36,8 @@ services:
|
|||||||
- ${SSH_AUTH_SOCK}:/ssh-auth-sock
|
- ${SSH_AUTH_SOCK}:/ssh-auth-sock
|
||||||
- ${HOME}/.ssh:/home/app/.ssh
|
- ${HOME}/.ssh:/home/app/.ssh
|
||||||
- dev_vol:/home/app
|
- dev_vol:/home/app
|
||||||
|
environment:
|
||||||
|
- PHRASEANET_PROJECT_NAME
|
||||||
|
|
||||||
phraseanet:
|
phraseanet:
|
||||||
environment:
|
environment:
|
||||||
|
@@ -5,6 +5,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
target: phraseanet-nginx
|
target: phraseanet-nginx
|
||||||
|
args:
|
||||||
|
- SSH_PRIVATE_KEY=${PHRASEANET_SSH_PRIVATE_KEY}
|
||||||
|
- PHRASEANET_PLUGINS=${PHRASEANET_PLUGINS}
|
||||||
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-nginx:$PHRASEANET_DOCKER_TAG
|
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-nginx:$PHRASEANET_DOCKER_TAG
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
volumes:
|
volumes:
|
||||||
@@ -21,6 +24,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
target: phraseanet-fpm
|
target: phraseanet-fpm
|
||||||
|
args:
|
||||||
|
- SSH_PRIVATE_KEY=${PHRASEANET_SSH_PRIVATE_KEY}
|
||||||
|
- PHRASEANET_PLUGINS=${PHRASEANET_PLUGINS}
|
||||||
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-fpm:$PHRASEANET_DOCKER_TAG
|
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-fpm:$PHRASEANET_DOCKER_TAG
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -29,6 +35,7 @@ services:
|
|||||||
- rabbitmq
|
- rabbitmq
|
||||||
- elasticsearch
|
- elasticsearch
|
||||||
environment:
|
environment:
|
||||||
|
- PHRASEANET_PROJECT_NAME
|
||||||
- MAX_BODY_SIZE
|
- MAX_BODY_SIZE
|
||||||
- MAX_INPUT_VARS
|
- MAX_INPUT_VARS
|
||||||
- OPCACHE_ENABLED
|
- OPCACHE_ENABLED
|
||||||
@@ -57,6 +64,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
target: phraseanet-worker
|
target: phraseanet-worker
|
||||||
|
args:
|
||||||
|
- SSH_PRIVATE_KEY=${PHRASEANET_SSH_PRIVATE_KEY}
|
||||||
|
- PHRASEANET_PLUGINS=${PHRASEANET_PLUGINS}
|
||||||
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-worker:$PHRASEANET_DOCKER_TAG
|
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-worker:$PHRASEANET_DOCKER_TAG
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -65,6 +75,7 @@ services:
|
|||||||
- rabbitmq
|
- rabbitmq
|
||||||
- elasticsearch
|
- elasticsearch
|
||||||
environment:
|
environment:
|
||||||
|
- PHRASEANET_PROJECT_NAME
|
||||||
- MAX_BODY_SIZE
|
- MAX_BODY_SIZE
|
||||||
- MAX_INPUT_VARS
|
- MAX_INPUT_VARS
|
||||||
- OPCACHE_ENABLED
|
- OPCACHE_ENABLED
|
||||||
|
50
docker/phraseanet/install-plugins
Executable file
50
docker/phraseanet/install-plugins
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
function setupStreaming() {
|
||||||
|
// Turn off output buffering
|
||||||
|
ini_set('output_buffering', 'off');
|
||||||
|
// Turn off PHP output compression
|
||||||
|
ini_set('zlib.output_compression', false);
|
||||||
|
// Disable Apache output buffering/compression
|
||||||
|
if (function_exists('apache_setenv')) {
|
||||||
|
apache_setenv('no-gzip', '1');
|
||||||
|
apache_setenv('dont-vary', '1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function runCommand($cmd){
|
||||||
|
echo "+ $cmd\n";
|
||||||
|
system($cmd, $return);
|
||||||
|
if (0 !== $return) {
|
||||||
|
throw new \Exception(sprintf('Error %d: %s', $return, $cmd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setupStreaming();
|
||||||
|
|
||||||
|
$plugins = trim(getenv('PHRASEANET_PLUGINS'));
|
||||||
|
if (empty($plugins)) {
|
||||||
|
echo "No plugin to install... SKIP\n";
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (explode(' ', $plugins) as $key => $plugin) {
|
||||||
|
$plugin = trim($plugin);
|
||||||
|
$repo = $plugin;
|
||||||
|
$branch = 'master';
|
||||||
|
if (1 === preg_match('#^(.+)\(([^)]+)\)$#', $plugin, $matches)) {
|
||||||
|
$repo = $matches[1];
|
||||||
|
$branch = $matches[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
$pluginTmpName = 'plugin' . $key;
|
||||||
|
$pluginPath = './plugin' . $key;
|
||||||
|
if (is_dir($pluginPath)) {
|
||||||
|
echo shell_exec(sprintf('rm -rf %s', $pluginPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
echo sprintf("Installing %s (branch: %s)\n", $repo, $branch);
|
||||||
|
runCommand(sprintf('git clone --single-branch --branch %s %s %s', $branch, $repo, $pluginPath));
|
||||||
|
|
||||||
|
runCommand(sprintf('bin/setup plugins:add %s', $pluginPath));
|
||||||
|
|
||||||
|
echo shell_exec(sprintf('rm -rf %s', $pluginPath));
|
||||||
|
}
|
Reference in New Issue
Block a user