Commit 4f46f5ea authored by zauberstuhl's avatar zauberstuhl
Browse files

Add friendica image

parent a62a6d3c
Pipeline #2107 passed with stage
in 46 seconds
......@@ -3,20 +3,29 @@
deploy=$([ "$1" == "deploy" ] && echo 1 || echo 0);
registry="registry.git.feneas.org/feneas/infrastructure/docker-images";
for dir in $(ls); do
if [ -d "$dir" ]; then
version=$(git tag -l "*-${dir}" --sort=-refname \
| head -1 | sed "s/^\(.*\)-${dir}/\1/");
function build() {
local dir=$1;
local version=$(git tag -l "*-${dir}" --sort=-refname \
| head -1 | sed "s/^\(.*\)-${dir}/\1/");
if [ "$version" != "" ] && [ -f "$dir/Dockerfile" ]; then
echo -ne "\n\nSTART BUILDING ${dir}:${version}\n\n"
docker build -t ${registry}/${dir}:${version} ${dir}
docker tag ${registry}/${dir}:${version} ${registry}/${dir}:latest
if [ "$deploy" == "1" ]; then
echo -ne "\n\nDEPLOYING ${dir}:${version}\n\n"
docker push ${registry}/${dir}:${version}
docker push ${registry}/${dir}:latest
fi
if [ "$version" != "" ] && [ -f "$dir/Dockerfile" ]; then
echo -ne "\n\nSTART BUILDING ${dir}:${version}\n\n"
docker build -t ${registry}/${dir}:${version} ${dir} || exit 1;
docker tag ${registry}/${dir}:${version} ${registry}/${dir}:latest || exit 1;
if [ "$deploy" == "1" ]; then
echo -ne "\n\nDEPLOYING ${dir}:${version}\n\n"
docker push ${registry}/${dir}:${version} || exit 1;
docker push ${registry}/${dir}:latest || exit 1;
fi
fi
done
}
if [ "$directory" == "" ]; then
for directory in $(ls); do
if [ -d "$directory" ]; then
build "$directory";
fi
done
else
build "$directory";
fi
FROM friendica/server:stable
COPY docker-entrypoint.patch /tmp/
COPY env_secrets_expand.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/env_secrets_expand.sh
RUN patch /entrypoint.sh </tmp/docker-entrypoint.patch
RUN rm /tmp/docker-entrypoint.patch
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
--- /entrypoint.sh 2019-08-06 18:14:08.495853066 +0200
+++ /entrypoint.sh 2019-08-06 18:16:41.602632706 +0200
@@ -1,6 +1,9 @@
#!/bin/sh
set -eu
+# parse docker environment secrets
+. /usr/local/bin/env_secrets_expand.sh
+
# run an command with the www-data user
run_as() {
if [ "$(id -u)" -eq 0 ]; then
#!/bin/sh
: ${ENV_SECRETS_DIR:=/run/secrets}
env_secret_debug()
{
if [ ! -z "$ENV_SECRETS_DEBUG" ]; then
echo -e "\033[1m$@\033[0m"
fi
}
# usage: env_secret_expand VAR
# ie: env_secret_expand 'XYZ_DB_PASSWORD'
# (will check for "$XYZ_DB_PASSWORD" variable value for a placeholder that defines the
# name of the docker secret to use instead of the original value. For example:
# XYZ_DB_PASSWORD={{DOCKER-SECRET:my-db.secret}}
env_secret_expand() {
var="$1"
eval val=\$$var
if secret_name=$(expr match "$val" "{{DOCKER-SECRET:\([^}]\+\)}}$"); then
secret="${ENV_SECRETS_DIR}/${secret_name}"
env_secret_debug "Secret file for $var: $secret"
if [ -f "$secret" ]; then
val=$(cat "${secret}")
export "$var"="$val"
env_secret_debug "Expanded variable: $var=$val"
else
env_secret_debug "Secret file does not exist! $secret"
fi
fi
}
env_secrets_expand() {
for env_var in $(printenv | cut -f1 -d"=")
do
env_secret_expand $env_var
done
if [ ! -z "$ENV_SECRETS_DEBUG" ]; then
echo -e "\n\033[1mExpanded environment variables\033[0m"
printenv
fi
}
env_secrets_expand
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment