Skip to content

Commit

Permalink
Revert "added support for installing plugins such as apoc at runtime"
Browse files Browse the repository at this point in the history
This reverts commit 3610caa.
  • Loading branch information
glindroth committed Jun 27, 2019
1 parent 822872d commit ec4cbd2
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 184 deletions.
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,11 @@ tmp/.image-id-%: tmp/local-context-%/.sentinel
$(<D)
> echo -n $$image >$@

tmp/neo4jlabs-plugins.json: ./neo4jlabs-plugins.json
> mkdir -p $(@D)
> cp $< $@

tmp/local-context-%/.sentinel: tmp/image-%/.sentinel in/$(call tarball,%,$(NEO4J_VERSION)) tmp/neo4jlabs-plugins.json
tmp/local-context-%/.sentinel: tmp/image-%/.sentinel in/$(call tarball,%,$(NEO4J_VERSION))
> rm -rf $(@D)
> mkdir -p $(@D)
> cp -r $(<D)/* $(@D)
> cp $(filter %.tar.gz,$^) $(@D)/local-package
> cp $(filter %.json,$^) $(@D)/local-package
> touch $@

tmp/image-%/.sentinel: src/$(series)/Dockerfile src/$(series)/docker-entrypoint.sh \
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ docker run \
neo4j:3.0
```

# Neo4j Labs Plugins

## Installation on container startup

Neo4j Labs plugins can be installed from github during container startup. Set the `NEO4JLABS_PLUGINS` environment variable to a json list of plugins to install. e.g. `["graph-algorithms", "graphql"]`.

# Getting support and contributing

Please create issues and pull requests in the Github repository.
6 changes: 0 additions & 6 deletions neo4jlabs-plugins.json

This file was deleted.

7 changes: 2 additions & 5 deletions src/3.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ RUN addgroup --system neo4j && adduser --system --no-create-home --home "${NEO4J
COPY ./local-package/* /tmp/

RUN apt update \
&& apt install -y curl gosu jq \
&& rm -rf /var/lib/apt/lists/* \
&& apt install -y curl gosu \
&& curl -L --fail --silent --show-error "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" > /sbin/tini \
&& echo "${TINI_SHA256} /sbin/tini" | sha256sum -c --strict --quiet \
&& chmod +x /sbin/tini \
Expand All @@ -32,9 +31,7 @@ RUN apt update \
&& chown -R neo4j:neo4j "${NEO4J_HOME}" \
&& chmod -R 777 "${NEO4J_HOME}" \
&& ln -s /data "${NEO4J_HOME}"/data \
&& ln -s /logs "${NEO4J_HOME}"/logs \
&& mv /tmp/neo4jlabs-plugins.json /neo4jlabs-plugins.json \
&& rm -rf /tmp/*
&& ln -s /logs "${NEO4J_HOME}"/logs

ENV PATH "${NEO4J_HOME}"/bin:$PATH

Expand Down
36 changes: 0 additions & 36 deletions src/3.3/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,6 @@ function check_mounted_folder_with_chown
fi
}

function load_plugin_from_github
{
# Load a plugin at runtime. The provided github repository must have a versions.json on the master branch with the
# correct format.
local _plugin_name="${1}" #e.g. apoc, graph-algorithms, graph-ql

local _plugins_dir="${NEO4J_HOME}/plugins"
if [ -d /plugins ]; then
local _plugins_dir="/plugins"
fi
local _versions_json="$(jq --raw-output "with_entries( select(.key==\"${_plugin_name}\") ) | to_entries[] | .value" /neo4jlabs-plugins.json )"
# Using the same name for the plugin irrespective of version ensures we don't end up with different versions of the same plugin
local _destination="${_plugins_dir}/${_plugin_name}.jar"
local _neo4j_version="$(neo4j --version | cut -d' ' -f2)"

# Now we call out to github to get the versions.json for this plugin and we parse that to find the url for the correct plugin jar for our neo4j version
local _plugin_jar_url="$(curl -L "${_versions_json}" | jq --raw-output ".[] | select(.neo4j==\"${_neo4j_version}\") | .jar")"
echo >&2 "Installing Plugin '${_plugin_name}' from ${_plugin_jar_url} to ${_destination} "
curl -o "${_destination}" -L "${_plugin_jar_url}"

if ! is_readable "${_destination}"; then
echo >&2 "Plugin at '${_destination}' is not readable"
exit 1
fi
}

# If we're running as root, then run as the neo4j user. Otherwise
# docker is running with --user and we simply use that user. Note
# that su-exec, despite its name, does not replicate the functionality
Expand Down Expand Up @@ -297,10 +271,6 @@ fi

if [ -d /plugins ]; then
if secure_mode_enabled; then
if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then
# We need write permissions
check_mounted_folder_with_chown "/plugins"
fi
check_mounted_folder_readable "/plugins"
fi
NEO4J_dbms_directories_plugins="/plugins"
Expand Down Expand Up @@ -376,12 +346,6 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do
fi
done

if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then
# NEO4JLABS_PLUGINS should be a json array of plugins like '["graph-algorithms", "apoc-procedures", "streams", "graphql"]'
for plugin_name in $(echo "${NEO4JLABS_PLUGINS}" | jq --raw-output '.[]'); do
load_plugin_from_github "${plugin_name}"
done
fi

[ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT}

Expand Down
7 changes: 2 additions & 5 deletions src/3.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ RUN addgroup --system neo4j && adduser --system --no-create-home --home "${NEO4J
COPY ./local-package/* /tmp/

RUN apt update \
&& apt install -y curl gosu jq \
&& rm -rf /var/lib/apt/lists/* \
&& apt install -y curl gosu \
&& curl -L --fail --silent --show-error "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" > /sbin/tini \
&& echo "${TINI_SHA256} /sbin/tini" | sha256sum -c --strict --quiet \
&& chmod +x /sbin/tini \
Expand All @@ -32,9 +31,7 @@ RUN apt update \
&& chown -R neo4j:neo4j "${NEO4J_HOME}" \
&& chmod -R 777 "${NEO4J_HOME}" \
&& ln -s /data "${NEO4J_HOME}"/data \
&& ln -s /logs "${NEO4J_HOME}"/logs \
&& mv /tmp/neo4jlabs-plugins.json /neo4jlabs-plugins.json \
&& rm -rf /tmp/*
&& ln -s /logs "${NEO4J_HOME}"/logs

ENV PATH "${NEO4J_HOME}"/bin:$PATH

Expand Down
36 changes: 0 additions & 36 deletions src/3.4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,6 @@ function check_mounted_folder_with_chown
fi
}

function load_plugin_from_github
{
# Load a plugin at runtime. The provided github repository must have a versions.json on the master branch with the
# correct format.
local _plugin_name="${1}" #e.g. apoc, graph-algorithms, graph-ql

local _plugins_dir="${NEO4J_HOME}/plugins"
if [ -d /plugins ]; then
local _plugins_dir="/plugins"
fi
local _versions_json="$(jq --raw-output "with_entries( select(.key==\"${_plugin_name}\") ) | to_entries[] | .value" /neo4jlabs-plugins.json )"
# Using the same name for the plugin irrespective of version ensures we don't end up with different versions of the same plugin
local _destination="${_plugins_dir}/${_plugin_name}.jar"
local _neo4j_version="$(neo4j --version | cut -d' ' -f2)"

# Now we call out to github to get the versions.json for this plugin and we parse that to find the url for the correct plugin jar for our neo4j version
local _plugin_jar_url="$(curl -L "${_versions_json}" | jq --raw-output ".[] | select(.neo4j==\"${_neo4j_version}\") | .jar")"
echo >&2 "Installing Plugin '${_plugin_name}' from ${_plugin_jar_url} to ${_destination} "
curl -o "${_destination}" -L "${_plugin_jar_url}"

if ! is_readable "${_destination}"; then
echo >&2 "Plugin at '${_destination}' is not readable"
exit 1
fi
}

# If we're running as root, then run as the neo4j user. Otherwise
# docker is running with --user and we simply use that user. Note
# that su-exec, despite its name, does not replicate the functionality
Expand Down Expand Up @@ -290,10 +264,6 @@ fi

if [ -d /plugins ]; then
if secure_mode_enabled; then
if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then
# We need write permissions
check_mounted_folder_with_chown "/plugins"
fi
check_mounted_folder_readable "/plugins"
fi
NEO4J_dbms_directories_plugins="/plugins"
Expand Down Expand Up @@ -369,12 +339,6 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do
fi
done

if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then
# NEO4JLABS_PLUGINS should be a json array of plugins like '["graph-algorithms", "apoc-procedures", "streams", "graphql"]'
for plugin_name in $(echo "${NEO4JLABS_PLUGINS}" | jq --raw-output '.[]'); do
load_plugin_from_github "${plugin_name}"
done
fi

[ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT}

Expand Down
7 changes: 2 additions & 5 deletions src/3.5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ RUN addgroup --system neo4j && adduser --system --no-create-home --home "${NEO4J
COPY ./local-package/* /tmp/

RUN apt update \
&& apt install -y curl gosu jq \
&& rm -rf /var/lib/apt/lists/* \
&& apt install -y curl gosu \
&& curl -L --fail --silent --show-error "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini" > /sbin/tini \
&& echo "${TINI_SHA256} /sbin/tini" | sha256sum -c --strict --quiet \
&& chmod +x /sbin/tini \
Expand All @@ -32,9 +31,7 @@ RUN apt update \
&& chown -R neo4j:neo4j "${NEO4J_HOME}" \
&& chmod -R 777 "${NEO4J_HOME}" \
&& ln -s /data "${NEO4J_HOME}"/data \
&& ln -s /logs "${NEO4J_HOME}"/logs \
&& mv /tmp/neo4jlabs-plugins.json /neo4jlabs-plugins.json \
&& rm -rf /tmp/*
&& ln -s /logs "${NEO4J_HOME}"/logs

ENV PATH "${NEO4J_HOME}"/bin:$PATH

Expand Down
36 changes: 0 additions & 36 deletions src/3.5/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,6 @@ function check_mounted_folder_with_chown
fi
}

function load_plugin_from_github
{
# Load a plugin at runtime. The provided github repository must have a versions.json on the master branch with the
# correct format.
local _plugin_name="${1}" #e.g. apoc, graph-algorithms, graph-ql

local _plugins_dir="${NEO4J_HOME}/plugins"
if [ -d /plugins ]; then
local _plugins_dir="/plugins"
fi
local _versions_json="$(jq --raw-output "with_entries( select(.key==\"${_plugin_name}\") ) | to_entries[] | .value" /neo4jlabs-plugins.json )"
# Using the same name for the plugin irrespective of version ensures we don't end up with different versions of the same plugin
local _destination="${_plugins_dir}/${_plugin_name}.jar"
local _neo4j_version="$(neo4j --version | cut -d' ' -f2)"

# Now we call out to github to get the versions.json for this plugin and we parse that to find the url for the correct plugin jar for our neo4j version
local _plugin_jar_url="$(curl -L "${_versions_json}" | jq --raw-output ".[] | select(.neo4j==\"${_neo4j_version}\") | .jar")"
echo >&2 "Installing Plugin '${_plugin_name}' from ${_plugin_jar_url} to ${_destination} "
curl -o "${_destination}" -L "${_plugin_jar_url}"

if ! is_readable "${_destination}"; then
echo >&2 "Plugin at '${_destination}' is not readable"
exit 1
fi
}

# If we're running as root, then run as the neo4j user. Otherwise
# docker is running with --user and we simply use that user. Note
# that su-exec, despite its name, does not replicate the functionality
Expand Down Expand Up @@ -290,10 +264,6 @@ fi

if [ -d /plugins ]; then
if secure_mode_enabled; then
if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then
# We need write permissions
check_mounted_folder_with_chown "/plugins"
fi
check_mounted_folder_readable "/plugins"
fi
NEO4J_dbms_directories_plugins="/plugins"
Expand Down Expand Up @@ -369,12 +339,6 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do
fi
done

if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then
# NEO4JLABS_PLUGINS should be a json array of plugins like '["graph-algorithms", "apoc-procedures", "streams", "graphql"]'
for plugin_name in $(echo "${NEO4JLABS_PLUGINS}" | jq --raw-output '.[]'); do
load_plugin_from_github "${plugin_name}"
done
fi

[ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT}

Expand Down
43 changes: 0 additions & 43 deletions test/test-apoc-download

This file was deleted.

0 comments on commit ec4cbd2

Please sign in to comment.