Skip to content

Commit

Permalink
Merge pull request #151 from dokku/faster-es-create
Browse files Browse the repository at this point in the history
fix: use a temporary container to force set permissions on elasticsearch config and data
  • Loading branch information
josegonzalez authored May 28, 2023
2 parents 06834d4 + 6d3c307 commit 1524d3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ service_create_container() {
LINK_CONTAINER_DOCKER_ARGS+=("--network=${network}")
fi

dokku_log_info2 "Set file permissions for config"
"$DOCKER_BIN" container run --rm "--volume=$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/usr/share/elasticsearch/config" "--volume=$SERVICE_HOST_ROOT/data:/usr/share/elasticsearch/data" --entrypoint "" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" chown -R 1000:0 /usr/share/elasticsearch/config
dokku_log_info2 "Set file permissions for data"
"$DOCKER_BIN" container run --rm "--volume=$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/usr/share/elasticsearch/config" "--volume=$SERVICE_HOST_ROOT/data:/usr/share/elasticsearch/data" --entrypoint "" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" chown -R 1000:0 /usr/share/elasticsearch/data

# shellcheck disable=SC2086
suppress_output "$DOCKER_BIN" container create "${DOCKER_ARGS[@]}" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" $CONFIG_OPTIONS

Expand All @@ -141,10 +146,6 @@ service_create_container() {
done < <(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-start-network" | tr "," "\n")
fi

retry-docker-command "$(cat "$SERVICE_ROOT/ID")" "chown -R 1000:0 /usr/share/elasticsearch/config; chown 1000:0 /usr/share/elasticsearch/data"

"$DOCKER_BIN" container restart "$(cat "$SERVICE_ROOT/ID")" >/dev/null

dokku_log_verbose_quiet "Waiting for container to be ready"
if ! suppress_output "$DOCKER_BIN" container run "${LINK_CONTAINER_DOCKER_ARGS[@]}" "$PLUGIN_WAIT_IMAGE" -c "$network_alias:$PLUGIN_DATASTORE_WAIT_PORT" -t 60; then
dokku_log_info2_quiet "Start of $SERVICE container output"
Expand Down

0 comments on commit 1524d3e

Please sign in to comment.