Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfc0f18759 | ||
|
|
9df82c58da | ||
|
|
ee2d2f10f7 | ||
|
|
9f3d24ca9f | ||
|
|
6128801308 | ||
|
|
8edb644d11 | ||
|
|
3181bb114e | ||
|
|
b722939dbb | ||
|
|
7b7da09a76 | ||
|
|
17f3ce2188 | ||
|
|
746b276202 | ||
|
|
bbc7b0fc71 | ||
|
|
f9e5067aa8 | ||
|
|
09926fbecd |
@@ -1 +1 @@
|
|||||||
FROM postgres:14.5
|
FROM postgres:15.3
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# dokku postgres [](https://github.com/dokku/dokku-postgres/actions/workflows/ci.yml?query=branch%3Amaster) [](https://webchat.libera.chat/?channels=dokku)
|
# dokku postgres [](https://github.com/dokku/dokku-postgres/actions/workflows/ci.yml?query=branch%3Amaster) [](https://webchat.libera.chat/?channels=dokku)
|
||||||
|
|
||||||
Official postgres plugin for dokku. Currently defaults to installing [postgres 14.5](https://hub.docker.com/_/postgres/).
|
Official postgres plugin for dokku. Currently defaults to installing [postgres 15.3](https://hub.docker.com/_/postgres/).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
|||||||
107
common-functions
107
common-functions
@@ -62,7 +62,7 @@ fn-services-list() {
|
|||||||
[[ -d $f ]] || continue
|
[[ -d $f ]] || continue
|
||||||
services+=("$f")
|
services+=("$f")
|
||||||
done
|
done
|
||||||
popd &>/dev/null || pushd "/tmp" >/dev/null
|
popd >/dev/null 2>&1 || pushd "/tmp" >/dev/null
|
||||||
|
|
||||||
if [[ "${#services[@]}" -eq 0 ]]; then
|
if [[ "${#services[@]}" -eq 0 ]]; then
|
||||||
return
|
return
|
||||||
@@ -282,7 +282,7 @@ service_backup() {
|
|||||||
BACKUP_TMPDIR=$(mktemp -d --tmpdir)
|
BACKUP_TMPDIR=$(mktemp -d --tmpdir)
|
||||||
trap 'rm -rf "$BACKUP_TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
trap 'rm -rf "$BACKUP_TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||||
|
|
||||||
"$DOCKER_BIN" container inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
"$DOCKER_BIN" container inspect "$ID" >/dev/null 2>&1 || dokku_log_fail "Service container does not exist"
|
||||||
is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running"
|
is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running"
|
||||||
|
|
||||||
(service_export "$SERVICE" >"${BACKUP_TMPDIR}/export")
|
(service_export "$SERVICE" >"${BACKUP_TMPDIR}/export")
|
||||||
@@ -457,7 +457,7 @@ service_container_rm() {
|
|||||||
local ID
|
local ID
|
||||||
|
|
||||||
service_pause "$SERVICE"
|
service_pause "$SERVICE"
|
||||||
ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$") || true
|
||||||
# this may be 'true' in tests...
|
# this may be 'true' in tests...
|
||||||
if [[ -z "$ID" ]] || [[ "$ID" == "true" ]]; then
|
if [[ -z "$ID" ]] || [[ "$ID" == "true" ]]; then
|
||||||
return 0
|
return 0
|
||||||
@@ -483,7 +483,7 @@ service_enter() {
|
|||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local ID="$(cat "$SERVICE_ROOT/ID")"
|
local ID="$(cat "$SERVICE_ROOT/ID")"
|
||||||
|
|
||||||
"$DOCKER_BIN" container inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
"$DOCKER_BIN" container inspect "$ID" >/dev/null 2>&1 || dokku_log_fail "Service container does not exist"
|
||||||
is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running"
|
is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running"
|
||||||
|
|
||||||
local EXEC_CMD=""
|
local EXEC_CMD=""
|
||||||
@@ -691,7 +691,7 @@ service_logs() {
|
|||||||
DOKKU_LOGS_ARGS+=" --follow"
|
DOKKU_LOGS_ARGS+=" --follow"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$DOCKER_BIN" container inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
"$DOCKER_BIN" container inspect "$ID" >/dev/null 2>&1 || dokku_log_fail "Service container does not exist"
|
||||||
is_container_status "$ID" "Running" || dokku_log_warn "Service logs may not be output as service is not running"
|
is_container_status "$ID" "Running" || dokku_log_warn "Service logs may not be output as service is not running"
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
@@ -810,39 +810,36 @@ service_root_password() {
|
|||||||
|
|
||||||
service_port_expose() {
|
service_port_expose() {
|
||||||
declare desc="wrapper for exposing service ports"
|
declare desc="wrapper for exposing service ports"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1" PORTS=(${@:2})
|
||||||
service_start "$SERVICE" "true"
|
|
||||||
service_port_unpause "$SERVICE" "true" "${@:2}"
|
|
||||||
}
|
|
||||||
|
|
||||||
service_port_pause() {
|
|
||||||
declare desc="pause service exposure"
|
|
||||||
declare SERVICE="$1" LOG_FAIL="$2"
|
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local EXPOSED_NAME="$(get_service_name "$SERVICE").ambassador"
|
|
||||||
local PORT_FILE="$SERVICE_ROOT/PORT"
|
local PORT_FILE="$SERVICE_ROOT/PORT"
|
||||||
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
|
local EXPOSED_NAME="$SERVICE_NAME.ambassador"
|
||||||
|
|
||||||
if [[ "$LOG_FAIL" == "true" ]]; then
|
if [[ ${#PORTS[@]} -eq 0 ]]; then
|
||||||
[[ ! -f "$PORT_FILE" ]] && dokku_log_fail "Service not exposed"
|
# shellcheck disable=SC2206
|
||||||
else
|
PORTS=(${PORTS[@]:-$(get_random_ports ${#PLUGIN_DATASTORE_PORTS[@]})})
|
||||||
[[ ! -f "$PORT_FILE" ]] && return 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local GREP_NAME="^/${EXPOSED_NAME}$"
|
[[ "${#PORTS[@]}" != "${#PLUGIN_DATASTORE_PORTS[@]}" ]] && dokku_log_fail "${#PLUGIN_DATASTORE_PORTS[@]} ports to be exposed need to be provided in the following order: ${PLUGIN_DATASTORE_PORTS[*]}"
|
||||||
local CONTAINER_NAME="$("$DOCKER_BIN" container ps -f name="$GREP_NAME" --format "{{.Names}}")"
|
|
||||||
if [[ -z "$CONTAINER_NAME" ]]; then
|
if [[ -s "$PORT_FILE" ]]; then
|
||||||
if [[ "$LOG_FAIL" == "true" ]]; then
|
# shellcheck disable=SC2207
|
||||||
dokku_log_info1 "Service $SERVICE unexposed"
|
PORTS=($(cat "$PORT_FILE"))
|
||||||
fi
|
dokku_log_fail "Service $SERVICE already exposed on port(s) ${PORTS[*]}"
|
||||||
|
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if "$DOCKER_BIN" container inspect "$EXPOSED_NAME" >/dev/null 2>&1; then
|
||||||
|
dokku_log_warn "Service $SERVICE has an untracked expose container, removing"
|
||||||
"$DOCKER_BIN" container stop "$EXPOSED_NAME" >/dev/null 2>&1 || true
|
"$DOCKER_BIN" container stop "$EXPOSED_NAME" >/dev/null 2>&1 || true
|
||||||
"$DOCKER_BIN" container rm "$EXPOSED_NAME" >/dev/null 2>&1 || true
|
suppress_output "$DOCKER_BIN" container rm "$EXPOSED_NAME"
|
||||||
if [[ "$LOG_FAIL" == "true" ]]; then
|
|
||||||
dokku_log_info1 "Service $SERVICE unexposed"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "${PORTS[@]}" >"$PORT_FILE"
|
||||||
|
|
||||||
|
service_start "$SERVICE" "true"
|
||||||
|
service_port_reconcile_status "$SERVICE"
|
||||||
|
dokku_log_info1 "Service $SERVICE exposed on port(s) [container->host]: $(service_exposed_ports "$SERVICE")"
|
||||||
}
|
}
|
||||||
|
|
||||||
service_port_unexpose() {
|
service_port_unexpose() {
|
||||||
@@ -850,39 +847,41 @@ service_port_unexpose() {
|
|||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local PORT_FILE="$SERVICE_ROOT/PORT"
|
local PORT_FILE="$SERVICE_ROOT/PORT"
|
||||||
service_port_pause "$SERVICE" "true"
|
|
||||||
rm -rf "$PORT_FILE"
|
rm -rf "$PORT_FILE"
|
||||||
|
service_port_reconcile_status "$SERVICE"
|
||||||
|
dokku_log_info1 "Service $SERVICE unexposed"
|
||||||
}
|
}
|
||||||
|
|
||||||
service_port_unpause() {
|
service_port_reconcile_status() {
|
||||||
declare desc="start service exposure"
|
declare SERVICE="$1"
|
||||||
declare SERVICE="$1" LOG_FAIL="$2"
|
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
|
||||||
local EXPOSED_NAME="${SERVICE_NAME}.ambassador"
|
|
||||||
local PORT_FILE="$SERVICE_ROOT/PORT"
|
local PORT_FILE="$SERVICE_ROOT/PORT"
|
||||||
# shellcheck disable=SC2068
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
local PORTS=(${@:3})
|
local EXPOSED_NAME="$SERVICE_NAME.ambassador"
|
||||||
# shellcheck disable=SC2068
|
|
||||||
PORTS=(${PORTS[@]:-$(get_random_ports ${#PLUGIN_DATASTORE_PORTS[@]})})
|
|
||||||
local ID=$(cat "$SERVICE_ROOT/ID")
|
|
||||||
|
|
||||||
[[ "${#PORTS[@]}" != "${#PLUGIN_DATASTORE_PORTS[@]}" ]] && dokku_log_fail "${#PLUGIN_DATASTORE_PORTS[@]} ports to be exposed need to be provided in the following order: ${PLUGIN_DATASTORE_PORTS[*]}"
|
if [[ ! -s "$PORT_FILE" ]]; then
|
||||||
|
if "$DOCKER_BIN" container inspect "$EXPOSED_NAME" >/dev/null 2>&1; then
|
||||||
if [[ "$LOG_FAIL" == "true" ]]; then
|
"$DOCKER_BIN" container stop "$EXPOSED_NAME" >/dev/null 2>&1 || true
|
||||||
[[ -f "$PORT_FILE" ]] && PORTS=($(cat "$PORT_FILE")) && dokku_log_fail "Service $SERVICE already exposed on port(s) ${PORTS[*]}"
|
suppress_output "$DOCKER_BIN" container rm "$EXPOSED_NAME"
|
||||||
else
|
return $?
|
||||||
[[ ! -f "$PORT_FILE" ]] && return 0
|
fi
|
||||||
PORTS=($(cat "$PORT_FILE"))
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${PORTS[@]}" >"$PORT_FILE"
|
if is_container_status "$EXPOSED_NAME" "Running"; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if "$DOCKER_BIN" container inspect "$EXPOSED_NAME" >/dev/null 2>&1; then
|
||||||
|
suppress_output "$DOCKER_BIN" container start "$EXPOSED_NAME"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2207
|
||||||
|
PORTS=($(cat "$PORT_FILE"))
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
"$DOCKER_BIN" container run -d --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" --name "$EXPOSED_NAME" $(docker_ports_options "${PORTS[@]}") --restart always --label dokku=ambassador --label "dokku.ambassador=$PLUGIN_COMMAND_PREFIX" "$PLUGIN_AMBASSADOR_IMAGE" >/dev/null
|
"$DOCKER_BIN" container run -d --link "$SERVICE_NAME:$PLUGIN_COMMAND_PREFIX" --name "$EXPOSED_NAME" $(docker_ports_options "${PORTS[@]}") --restart always --label dokku=ambassador --label "dokku.ambassador=$PLUGIN_COMMAND_PREFIX" "$PLUGIN_AMBASSADOR_IMAGE" >/dev/null
|
||||||
if [[ "$LOG_FAIL" == "true" ]]; then
|
|
||||||
dokku_log_info1 "Service $SERVICE exposed on port(s) [container->host]: $(service_exposed_ports "$SERVICE")"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
service_promote() {
|
service_promote() {
|
||||||
@@ -940,13 +939,15 @@ service_pause() {
|
|||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
local ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
local ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "name=^/$SERVICE_NAME$") || true
|
||||||
[[ -z $ID ]] && dokku_log_warn "Service is already paused" && return 0
|
[[ -z $ID ]] && dokku_log_warn "Service is already paused" && return 0
|
||||||
|
|
||||||
if [[ -n $ID ]]; then
|
if [[ -n $ID ]]; then
|
||||||
dokku_log_info2_quiet "Pausing container"
|
dokku_log_info2_quiet "Pausing container"
|
||||||
"$DOCKER_BIN" container stop "$SERVICE_NAME" >/dev/null
|
"$DOCKER_BIN" container stop "$SERVICE_NAME" >/dev/null
|
||||||
service_port_pause "$SERVICE"
|
if "$DOCKER_BIN" container inspect "$ID" >/dev/null 2>&1; then
|
||||||
|
"$DOCKER_BIN" container stop "$SERVICE_NAME.ambassador" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
dokku_log_verbose_quiet "Container paused"
|
dokku_log_verbose_quiet "Container paused"
|
||||||
else
|
else
|
||||||
dokku_log_verbose_quiet "No container exists for $SERVICE"
|
dokku_log_verbose_quiet "No container exists for $SERVICE"
|
||||||
|
|||||||
14
functions
14
functions
@@ -126,6 +126,8 @@ service_create_container() {
|
|||||||
done < <(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-create-network" | tr "," "\n")
|
done < <(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-create-network" | tr "," "\n")
|
||||||
fi
|
fi
|
||||||
suppress_output "$DOCKER_BIN" container start "$(cat "$SERVICE_ROOT/ID")"
|
suppress_output "$DOCKER_BIN" container start "$(cat "$SERVICE_ROOT/ID")"
|
||||||
|
service_port_reconcile_status "$SERVICE"
|
||||||
|
|
||||||
if [[ -n "$(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-start-network")" ]]; then
|
if [[ -n "$(fn-plugin-property-get "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "post-start-network")" ]]; then
|
||||||
dokku_log_verbose_quiet "Connecting to networks after container start"
|
dokku_log_verbose_quiet "Connecting to networks after container start"
|
||||||
while read -r line || [[ -n "$line" ]]; do
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
@@ -147,10 +149,12 @@ service_create_container() {
|
|||||||
|
|
||||||
dokku_log_verbose_quiet "Securing connection to database"
|
dokku_log_verbose_quiet "Securing connection to database"
|
||||||
service_pause "$SERVICE" >/dev/null
|
service_pause "$SERVICE" >/dev/null
|
||||||
"$DOCKER_BIN" container run --rm -i -v "$SERVICE_HOST_ROOT/data:/var/lib/postgresql/data" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" bash -s <"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/scripts/enable_ssl.sh" &>/dev/null
|
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/scripts/create_ssl_certs.sh" "$SERVICE_HOST_ROOT" &>/dev/null
|
||||||
|
"$DOCKER_BIN" container run --rm -i -v "$SERVICE_HOST_ROOT/data:/var/lib/postgresql/data" -v "$SERVICE_HOST_ROOT/certs:/var/lib/postgresql/certs" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" bash -s <"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/scripts/enable_ssl.sh" &>/dev/null
|
||||||
|
rm -rf "$SERVICE_HOST_ROOT/certs"
|
||||||
|
|
||||||
suppress_output "$DOCKER_BIN" container start "$(cat "$SERVICE_ROOT/ID")"
|
suppress_output "$DOCKER_BIN" container start "$(cat "$SERVICE_ROOT/ID")"
|
||||||
service_port_unpause "$SERVICE"
|
service_port_reconcile_status "$SERVICE"
|
||||||
|
|
||||||
dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE"
|
dokku_log_info2 "$PLUGIN_SERVICE container created: $SERVICE"
|
||||||
service_info "$SERVICE"
|
service_info "$SERVICE"
|
||||||
@@ -189,7 +193,7 @@ service_start() {
|
|||||||
local QUIET="$2"
|
local QUIET="$2"
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
local ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "status=running" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
local ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "status=running" --filter "name=^/$SERVICE_NAME$") || true
|
||||||
if [[ -n $ID ]]; then
|
if [[ -n $ID ]]; then
|
||||||
[[ -z $QUIET ]] && dokku_log_warn "Service is already started"
|
[[ -z $QUIET ]] && dokku_log_warn "Service is already started"
|
||||||
if [[ ! -f "$SERVICE_ROOT/ID" ]] || [[ "$(cat "$SERVICE_ROOT/ID")" != "$ID" ]]; then
|
if [[ ! -f "$SERVICE_ROOT/ID" ]] || [[ "$(cat "$SERVICE_ROOT/ID")" != "$ID" ]]; then
|
||||||
@@ -200,12 +204,12 @@ service_start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
dokku_log_info2_quiet "Starting container"
|
dokku_log_info2_quiet "Starting container"
|
||||||
local PREVIOUS_ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "status=exited" --filter "name=^/$SERVICE_NAME$" --format '{{ .ID }}') || true
|
local PREVIOUS_ID=$("$DOCKER_BIN" container ps -aq --no-trunc --filter "status=exited" --filter "name=^/$SERVICE_NAME$") || true
|
||||||
local PASSWORD="$(service_password "$SERVICE")"
|
local PASSWORD="$(service_password "$SERVICE")"
|
||||||
|
|
||||||
if [[ -n $PREVIOUS_ID ]]; then
|
if [[ -n $PREVIOUS_ID ]]; then
|
||||||
"$DOCKER_BIN" container start "$PREVIOUS_ID" >/dev/null
|
"$DOCKER_BIN" container start "$PREVIOUS_ID" >/dev/null
|
||||||
service_port_unpause "$SERVICE"
|
service_port_reconcile_status "$SERVICE"
|
||||||
dokku_log_info2 "Container started"
|
dokku_log_info2 "Container started"
|
||||||
elif service_image_exists "$SERVICE" && [[ -n "$PASSWORD" ]]; then
|
elif service_image_exists "$SERVICE" && [[ -n "$PASSWORD" ]]; then
|
||||||
service_create_container "$SERVICE"
|
service_create_container "$SERVICE"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[plugin]
|
[plugin]
|
||||||
description = "dokku postgres service plugin"
|
description = "dokku postgres service plugin"
|
||||||
version = "1.31.0"
|
version = "1.34.0"
|
||||||
[plugin.config]
|
[plugin.config]
|
||||||
|
|||||||
7
scripts/create_ssl_certs.sh
Executable file
7
scripts/create_ssl_certs.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
postgres_service_dir="$1"
|
||||||
|
|
||||||
|
cd "$postgres_service_dir"
|
||||||
|
mkdir certs && cd certs
|
||||||
|
openssl req -new -newkey rsa:4096 -x509 -days 365000 -nodes -out server.crt -keyout server.key -batch
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
pushd /var/lib/postgresql/data >/dev/null
|
|
||||||
openssl req -new -newkey rsa:4096 -x509 -days 365000 -nodes -out server.crt -keyout server.key -batch
|
cd /var/lib/postgresql/data
|
||||||
|
|
||||||
|
cp ../certs/* .
|
||||||
|
chown postgres:postgres server.key
|
||||||
chmod 600 server.key
|
chmod 600 server.key
|
||||||
|
|
||||||
sed -i "s/^#ssl = off/ssl = on/" postgresql.conf
|
sed -i "s/^#ssl = off/ssl = on/" postgresql.conf
|
||||||
sed -i "s/^#ssl_ciphers =.*/ssl_ciphers = 'AES256+EECDH:AES256+EDH'/" postgresql.conf
|
sed -i "s/^#ssl_ciphers =.*/ssl_ciphers = 'AES256+EECDH:AES256+EDH'/" postgresql.conf
|
||||||
popd >/dev/null
|
|
||||||
|
|||||||
@@ -2,29 +2,65 @@
|
|||||||
load test_helper
|
load test_helper
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "($PLUGIN_COMMAND_PREFIX:expose) error when there are no arguments" {
|
@test "($PLUGIN_COMMAND_PREFIX:expose) error when there are no arguments" {
|
||||||
run dokku "$PLUGIN_COMMAND_PREFIX:expose"
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
assert_contains "${lines[*]}" "Please specify a valid name for the service"
|
assert_contains "${lines[*]}" "Please specify a valid name for the service"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "($PLUGIN_COMMAND_PREFIX:expose) error when service does not exist" {
|
@test "($PLUGIN_COMMAND_PREFIX:expose) error when service does not exist" {
|
||||||
run dokku "$PLUGIN_COMMAND_PREFIX:expose" not_existing_service
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" not_existing_service
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:expose) error when already exposed" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" ls
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" ls
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
assert_contains "${lines[*]}" "Service ls already exposed on port(s)"
|
||||||
|
|
||||||
|
run sudo rm "$PLUGIN_DATA_ROOT/ls/PORT"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" ls
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_contains "${lines[*]}" "Service ls has an untracked expose container, removing"
|
||||||
|
}
|
||||||
|
|
||||||
@test "($PLUGIN_COMMAND_PREFIX:expose) success when not providing custom ports" {
|
@test "($PLUGIN_COMMAND_PREFIX:expose) success when not providing custom ports" {
|
||||||
run dokku "$PLUGIN_COMMAND_PREFIX:expose" l
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" ls
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
[[ "${lines[*]}" =~ exposed\ on\ port\(s\)\ \[container\-\>host\]\:\ [[:digit:]]+ ]]
|
[[ "${lines[*]}" =~ exposed\ on\ port\(s\)\ \[container\-\>host\]\:\ [[:digit:]]+ ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "($PLUGIN_COMMAND_PREFIX:expose) success when providing custom ports" {
|
@test "($PLUGIN_COMMAND_PREFIX:expose) success when providing custom ports" {
|
||||||
run dokku "$PLUGIN_COMMAND_PREFIX:expose" l 4242
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" ls 4242
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
assert_contains "${lines[*]}" "exposed on port(s) [container->host]: 5432->4242"
|
assert_contains "${lines[*]}" "exposed on port(s) [container->host]: 5432->4242"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user