Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0e32d268e | ||
|
|
c22a2c5bca | ||
|
|
760c21b044 | ||
|
|
1f0cdba967 | ||
|
|
0d4a6bc320 | ||
|
|
0209f16188 | ||
|
|
e0c8375c3a | ||
|
|
3781dec5f7 | ||
|
|
84101e17e9 | ||
|
|
a68d2e71d0 | ||
|
|
d99ae93279 | ||
|
|
af01981e52 | ||
|
|
1c7d121a07 | ||
|
|
2f33b6deb3 | ||
|
|
78d74dfc3c |
@@ -1 +1 @@
|
|||||||
FROM postgres:13.4
|
FROM postgres:14.1
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -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 13.4](https://hub.docker.com/_/postgres/).
|
Official postgres plugin for dokku. Currently defaults to installing [postgres 14.1](https://hub.docker.com/_/postgres/).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ postgres:link <service> <app> [--link-flags...] # link the postgres service t
|
|||||||
postgres:linked <service> <app> # check if the postgres service is linked to an app
|
postgres:linked <service> <app> # check if the postgres service is linked to an app
|
||||||
postgres:links <service> # list all apps linked to the postgres service
|
postgres:links <service> # list all apps linked to the postgres service
|
||||||
postgres:list # list all postgres services
|
postgres:list # list all postgres services
|
||||||
postgres:logs <service> [-t|--tail] # print the most recent log(s) for this service
|
postgres:logs <service> [-t|--tail] <tail-num-optional> # print the most recent log(s) for this service
|
||||||
postgres:promote <service> <app> # promote service <service> as DATABASE_URL in <app>
|
postgres:promote <service> <app> # promote service <service> as DATABASE_URL in <app>
|
||||||
postgres:restart <service> # graceful shutdown and restart of the postgres service container
|
postgres:restart <service> # graceful shutdown and restart of the postgres service container
|
||||||
postgres:start <service> # start a previously stopped postgres service
|
postgres:start <service> # start a previously stopped postgres service
|
||||||
@@ -69,7 +69,7 @@ flags:
|
|||||||
- `-C|--custom-env "USER=alpha;HOST=beta"`: semi-colon delimited environment variables to start the service with
|
- `-C|--custom-env "USER=alpha;HOST=beta"`: semi-colon delimited environment variables to start the service with
|
||||||
- `-i|--image IMAGE`: the image name to start the service with
|
- `-i|--image IMAGE`: the image name to start the service with
|
||||||
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
||||||
- `-m|--memory MEMORY`: container memory limit (default: unlimited)
|
- `-m|--memory MEMORY`: container memory limit in megabytes (default: unlimited)
|
||||||
- `-p|--password PASSWORD`: override the user-level service password
|
- `-p|--password PASSWORD`: override the user-level service password
|
||||||
- `-r|--root-password PASSWORD`: override the root-level service password
|
- `-r|--root-password PASSWORD`: override the root-level service password
|
||||||
- `-s|--shm-size SHM_SIZE`: override shared memory size for postgres docker container
|
- `-s|--shm-size SHM_SIZE`: override shared memory size for postgres docker container
|
||||||
@@ -159,12 +159,12 @@ dokku postgres:list
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
# usage
|
# usage
|
||||||
dokku postgres:logs <service> [-t|--tail]
|
dokku postgres:logs <service> [-t|--tail] <tail-num-optional>
|
||||||
```
|
```
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
|
|
||||||
- `-t|--tail`: do not stop when end of the logs are reached and wait for additional output
|
- `-t|--tail [<tail-num>]`: do not stop when end of the logs are reached and wait for additional output
|
||||||
|
|
||||||
You can tail logs for a particular service:
|
You can tail logs for a particular service:
|
||||||
|
|
||||||
@@ -178,6 +178,12 @@ By default, logs will not be tailed, but you can do this with the --tail flag:
|
|||||||
dokku postgres:logs lollipop --tail
|
dokku postgres:logs lollipop --tail
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The default tail setting is to show all logs, but an initial count can also be specified:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
dokku postgres:logs lollipop --tail 5
|
||||||
|
```
|
||||||
|
|
||||||
### link the postgres service to the app
|
### link the postgres service to the app
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -472,7 +478,7 @@ flags:
|
|||||||
- `-C|--custom-env "USER=alpha;HOST=beta"`: semi-colon delimited environment variables to start the service with
|
- `-C|--custom-env "USER=alpha;HOST=beta"`: semi-colon delimited environment variables to start the service with
|
||||||
- `-i|--image IMAGE`: the image name to start the service with
|
- `-i|--image IMAGE`: the image name to start the service with
|
||||||
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
||||||
- `-m|--memory MEMORY`: container memory limit (default: unlimited)
|
- `-m|--memory MEMORY`: container memory limit in megabytes (default: unlimited)
|
||||||
- `-p|--password PASSWORD`: override the user-level service password
|
- `-p|--password PASSWORD`: override the user-level service password
|
||||||
- `-r|--root-password PASSWORD`: override the root-level service password
|
- `-r|--root-password PASSWORD`: override the root-level service password
|
||||||
- `-s|--shm-size SHM_SIZE`: override shared memory size for postgres docker container
|
- `-s|--shm-size SHM_SIZE`: override shared memory size for postgres docker container
|
||||||
|
|||||||
@@ -451,7 +451,7 @@ service_info() {
|
|||||||
|
|
||||||
local flag_map=(
|
local flag_map=(
|
||||||
"--config-dir: ${SERVICE_ROOT}/${PLUGIN_CONFIG_SUFFIX}"
|
"--config-dir: ${SERVICE_ROOT}/${PLUGIN_CONFIG_SUFFIX}"
|
||||||
"--config-options: $(cat "$SERVICE_ROOT/CONFIG_OPTIONS")"
|
"--config-options: $(cat "$SERVICE_ROOT/CONFIG_OPTIONS" 2>/dev/null || true)"
|
||||||
"--data-dir: ${SERVICE_ROOT}/data"
|
"--data-dir: ${SERVICE_ROOT}/data"
|
||||||
"--dsn: ${SERVICE_URL}"
|
"--dsn: ${SERVICE_URL}"
|
||||||
"--exposed-ports: $(service_exposed_ports "$SERVICE")"
|
"--exposed-ports: $(service_exposed_ports "$SERVICE")"
|
||||||
@@ -533,7 +533,11 @@ service_link() {
|
|||||||
fi
|
fi
|
||||||
[[ -n "$SERVICE_QUERYSTRING" ]] && SERVICE_URL="${SERVICE_URL}?${SERVICE_QUERYSTRING}"
|
[[ -n "$SERVICE_QUERYSTRING" ]] && SERVICE_URL="${SERVICE_URL}?${SERVICE_QUERYSTRING}"
|
||||||
plugn trigger service-action post-link "$SERVICE" "$APP"
|
plugn trigger service-action post-link "$SERVICE" "$APP"
|
||||||
config_set "$APP" "${ALIAS}_URL=$SERVICE_URL"
|
if [[ "$DOKKU_GLOBAL_FLAGS" == *"--no-restart"* ]]; then
|
||||||
|
config_set --no-restart "$APP" "${ALIAS}_URL=$SERVICE_URL"
|
||||||
|
else
|
||||||
|
config_set "$APP" "${ALIAS}_URL=$SERVICE_URL"
|
||||||
|
fi
|
||||||
plugn trigger service-action post-link-complete "$SERVICE" "$APP"
|
plugn trigger service-action post-link-complete "$SERVICE" "$APP"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,14 +582,14 @@ service_list() {
|
|||||||
|
|
||||||
service_logs() {
|
service_logs() {
|
||||||
declare desc="display logs for a service"
|
declare desc="display logs for a service"
|
||||||
declare SERVICE="$1" TAIL_FLAG="$2"
|
declare SERVICE="$1" TAIL_FLAG="$2" TAIL_COUNT="$3"
|
||||||
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")
|
||||||
local RE_INTEGER='^[0-9]+$'
|
local RE_INTEGER='^[0-9]+$'
|
||||||
|
|
||||||
DOKKU_LOGS_ARGS="--tail 100"
|
DOKKU_LOGS_ARGS="--tail $TAIL_COUNT"
|
||||||
if [[ "$TAIL_FLAG" == "-t" ]] || [[ "$TAIL_FLAG" == "--tail" ]]; then
|
if [[ "$TAIL_FLAG" == "-t" ]] || [[ "$TAIL_FLAG" == "--tail" ]]; then
|
||||||
DOKKU_LOGS_ARGS="--follow"
|
DOKKU_LOGS_ARGS+=" --follow"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
||||||
@@ -857,7 +861,11 @@ service_unlink() {
|
|||||||
|
|
||||||
[[ -z ${LINK[*]} ]] && dokku_log_fail "Not linked to app $APP"
|
[[ -z ${LINK[*]} ]] && dokku_log_fail "Not linked to app $APP"
|
||||||
plugn trigger service-action post-unlink "$SERVICE" "$APP"
|
plugn trigger service-action post-unlink "$SERVICE" "$APP"
|
||||||
config_unset "$APP" "${LINK[@]}"
|
if [[ "$DOKKU_GLOBAL_FLAGS" == *"--no-restart"* ]]; then
|
||||||
|
config_unset --no-restart "$APP" "${LINK[@]}"
|
||||||
|
else
|
||||||
|
config_unset "$APP" "${LINK[@]}"
|
||||||
|
fi
|
||||||
plugn trigger service-action post-unlink-complete "$SERVICE" "$APP"
|
plugn trigger service-action post-unlink-complete "$SERVICE" "$APP"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,6 +202,9 @@ fn-help-subcommand-args() {
|
|||||||
elif [[ "$arg" == *_LIST ]]; then
|
elif [[ "$arg" == *_LIST ]]; then
|
||||||
arg=${arg%_*}
|
arg=${arg%_*}
|
||||||
args+=" <${arg//_/-}...>"
|
args+=" <${arg//_/-}...>"
|
||||||
|
elif [[ "$arg" == *_OPTIONAL ]]; then
|
||||||
|
argName="${arg/_OPTIONAL/}"
|
||||||
|
args+=" [<${argName//_/-}>]"
|
||||||
else
|
else
|
||||||
args+=" <${arg//_/-}>"
|
args+=" <${arg//_/-}>"
|
||||||
fi
|
fi
|
||||||
|
|||||||
7
install
7
install
@@ -24,10 +24,10 @@ plugin-install() {
|
|||||||
pull-docker-image "$PLUGIN_WAIT_IMAGE"
|
pull-docker-image "$PLUGIN_WAIT_IMAGE"
|
||||||
|
|
||||||
mkdir -p "$PLUGIN_DATA_ROOT" || echo "Failed to create $PLUGIN_SERVICE data directory"
|
mkdir -p "$PLUGIN_DATA_ROOT" || echo "Failed to create $PLUGIN_SERVICE data directory"
|
||||||
chown dokku:dokku "$PLUGIN_DATA_ROOT"
|
chown "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "$PLUGIN_DATA_ROOT"
|
||||||
|
|
||||||
mkdir -p "$PLUGIN_CONFIG_ROOT" || echo "Failed to create $PLUGIN_SERVICE config directory"
|
mkdir -p "$PLUGIN_CONFIG_ROOT" || echo "Failed to create $PLUGIN_SERVICE config directory"
|
||||||
chown dokku:dokku "$PLUGIN_CONFIG_ROOT"
|
chown "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "$PLUGIN_CONFIG_ROOT"
|
||||||
|
|
||||||
rm -f "/etc/sudoers.d/dokku-${PLUGIN_COMMAND_PREFIX}*"
|
rm -f "/etc/sudoers.d/dokku-${PLUGIN_COMMAND_PREFIX}*"
|
||||||
_SUDOERS_FILE="/etc/sudoers.d/dokku-${PLUGIN_COMMAND_PREFIX}"
|
_SUDOERS_FILE="/etc/sudoers.d/dokku-${PLUGIN_COMMAND_PREFIX}"
|
||||||
@@ -56,8 +56,11 @@ EOL
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
chown "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "$SERVICE_ROOT/IMAGE" "$SERVICE_ROOT/IMAGE_VERSION"
|
||||||
|
|
||||||
if [[ -f "$SERVICE_ROOT/${PLUGIN_VARIABLE}_CONFIG_OPTIONS" ]]; then
|
if [[ -f "$SERVICE_ROOT/${PLUGIN_VARIABLE}_CONFIG_OPTIONS" ]]; then
|
||||||
mv "$SERVICE_ROOT/${PLUGIN_VARIABLE}_CONFIG_OPTIONS" "$SERVICE_ROOT/CONFIG_OPTIONS"
|
mv "$SERVICE_ROOT/${PLUGIN_VARIABLE}_CONFIG_OPTIONS" "$SERVICE_ROOT/CONFIG_OPTIONS"
|
||||||
|
chown "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "$SERVICE_ROOT/CONFIG_OPTIONS"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[plugin]
|
[plugin]
|
||||||
description = "dokku postgres service plugin"
|
description = "dokku postgres service plugin"
|
||||||
version = "1.16.0"
|
version = "1.19.3"
|
||||||
[plugin.config]
|
[plugin.config]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ service-clone-cmd() {
|
|||||||
#F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
|
#F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
|
||||||
#F -i|--image IMAGE, the image name to start the service with
|
#F -i|--image IMAGE, the image name to start the service with
|
||||||
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
|
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
|
||||||
#F -m|--memory MEMORY, container memory limit (default: unlimited)
|
#F -m|--memory MEMORY, container memory limit in megabytes (default: unlimited)
|
||||||
#F -p|--password PASSWORD, override the user-level service password
|
#F -p|--password PASSWORD, override the user-level service password
|
||||||
#F -r|--root-password PASSWORD, override the root-level service password
|
#F -r|--root-password PASSWORD, override the root-level service password
|
||||||
#F -s|--shm-size SHM_SIZE, override shared memory size for $PLUGIN_COMMAND_PREFIX docker container
|
#F -s|--shm-size SHM_SIZE, override shared memory size for $PLUGIN_COMMAND_PREFIX docker container
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ service-create-cmd() {
|
|||||||
#F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
|
#F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
|
||||||
#F -i|--image IMAGE, the image name to start the service with
|
#F -i|--image IMAGE, the image name to start the service with
|
||||||
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
|
#F -I|--image-version IMAGE_VERSION, the image version to start the service with
|
||||||
#F -m|--memory MEMORY, container memory limit (default: unlimited)
|
#F -m|--memory MEMORY, container memory limit in megabytes (default: unlimited)
|
||||||
#F -p|--password PASSWORD, override the user-level service password
|
#F -p|--password PASSWORD, override the user-level service password
|
||||||
#F -r|--root-password PASSWORD, override the root-level service password
|
#F -r|--root-password PASSWORD, override the root-level service password
|
||||||
#F -s|--shm-size SHM_SIZE, override shared memory size for $PLUGIN_COMMAND_PREFIX docker container
|
#F -s|--shm-size SHM_SIZE, override shared memory size for $PLUGIN_COMMAND_PREFIX docker container
|
||||||
|
|||||||
@@ -10,16 +10,18 @@ service-logs-cmd() {
|
|||||||
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop
|
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop
|
||||||
#E by default, logs will not be tailed, but you can do this with the --tail flag:
|
#E by default, logs will not be tailed, but you can do this with the --tail flag:
|
||||||
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop --tail
|
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop --tail
|
||||||
|
#E the default tail setting is to show all logs, but an initial count can also be specified
|
||||||
|
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop --tail 5
|
||||||
#A service, service to run command against
|
#A service, service to run command against
|
||||||
#F -t|--tail, do not stop when end of the logs are reached and wait for additional output
|
#F -t|--tail [<tail-num>], do not stop when end of the logs are reached and wait for additional output
|
||||||
declare desc="print the most recent log(s) for this service"
|
declare desc="print the most recent log(s) for this service"
|
||||||
local cmd="$PLUGIN_COMMAND_PREFIX:logs" argv=("$@")
|
local cmd="$PLUGIN_COMMAND_PREFIX:logs" argv=("$@")
|
||||||
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||||
declare SERVICE="$1" TAIL_FLAG="$2"
|
declare SERVICE="$1" TAIL_FLAG="$2" TAIL_NUM_OPTIONAL="${3:-all}"
|
||||||
|
|
||||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
||||||
verify_service_name "$SERVICE"
|
verify_service_name "$SERVICE"
|
||||||
service_logs "$SERVICE" "$TAIL_FLAG"
|
service_logs "$SERVICE" "$TAIL_FLAG" "$TAIL_NUM_OPTIONAL"
|
||||||
}
|
}
|
||||||
|
|
||||||
service-logs-cmd "$@"
|
service-logs-cmd "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user