dev: make devcontainer setup plugin agnostic
This commit is contained in:
24
.devcontainer/20_init_plugin
Executable file
24
.devcontainer/20_init_plugin
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
log-info() {
|
||||
declare desc="Log info formatter"
|
||||
echo " $*" 1>&2
|
||||
}
|
||||
|
||||
log-fail() {
|
||||
declare desc="Log fail formatter"
|
||||
echo "! $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
main() {
|
||||
dokku plugin:install
|
||||
|
||||
# built in the Dockerfile
|
||||
PLUGIN_NAME="$(source /tmp/.env && echo "$PLUGIN_NAME")"
|
||||
PLUGIN_VARIABLE="$(source /tmp/.env && echo "$PLUGIN_VARIABLE")"
|
||||
dokku config:set --global "${PLUGIN_VARIABLE}_HOST_ROOT=${SERVICE_HOST_ROOT}"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -9,11 +9,16 @@ RUN apt-get install --no-install-recommends -y build-essential && \
|
||||
chown -R dokku:dokku /mnt/dokku/home/dokku /mnt/dokku/var/lib/dokku/config /mnt/dokku/var/lib/dokku/data /mnt/dokku/var/lib/dokku/services && \
|
||||
echo "dokku.me" > /home/dokku/VHOST
|
||||
|
||||
ADD https://raw.githubusercontent.com/dokku/dokku/master/tests/dhparam.pem /mnt/dokku/etc/nginx/dhparam.pem
|
||||
|
||||
COPY .devcontainer/20_init_plugin /etc/my_init.d/20_init_plugin
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN source /tmp/config && \
|
||||
echo "export ${PLUGIN_DISABLE_PULL_VARIABLE}=true" > /tmp/.env && \
|
||||
echo "export PLUGIN_NAME=${PLUGIN_COMMAND_PREFIX}" >> /tmp/.env
|
||||
echo "export PLUGIN_NAME=${PLUGIN_COMMAND_PREFIX}" >> /tmp/.env && \
|
||||
echo "export PLUGIN_VARIABLE=${PLUGIN_VARIABLE}" >> /tmp/.env
|
||||
|
||||
RUN source /tmp/.env && \
|
||||
dokku plugin:install file:///tmp --name $PLUGIN_NAME && \
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
"dockerfile": "Dockerfile",
|
||||
"context": ".."
|
||||
},
|
||||
"runArgs": ["--init"],
|
||||
"containerEnv": {
|
||||
"SERVICE_HOST_ROOT": "${localWorkspaceFolder}/tmp/data"
|
||||
},
|
||||
"initializeCommand": ["mkdir", "-p", "tmp/data"],
|
||||
"mounts": [
|
||||
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
|
||||
"source=${localWorkspaceFolder}/tmp/data/,target=/var/lib/dokku/services/postgres/,type=bind"
|
||||
"source=${localWorkspaceFolder}/tmp/data/,target=/var/lib/dokku/services/,type=bind"
|
||||
],
|
||||
"containerEnv": {
|
||||
"POSTGRES_HOST_ROOT": "${localWorkspaceFolder}/tmp/data"
|
||||
}
|
||||
"overrideCommand": false,
|
||||
"runArgs": ["--init"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user