Skip to content

Commit

Permalink
Fix problems with container losing references to dokuwiki folders
Browse files Browse the repository at this point in the history
  • Loading branch information
vndmtrx committed Nov 21, 2024
1 parent b75f00a commit 16196ce
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
18 changes: 4 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ RUN curl -O https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz \

COPY files/ .

RUN mkdir -p /dokuwiki \
&& mv conf data /dokuwiki/ \
&& mv lib/plugins /dokuwiki/plugins \
&& mv lib/tpl /dokuwiki/tpl

FROM php:8.3-apache

LABEL maintainer="Eduardo N.S.R. <[email protected]>" \
Expand All @@ -31,6 +26,7 @@ LABEL maintainer="Eduardo N.S.R. <[email protected]>" \
RUN apt-get update && apt-get install -y libldap2-dev libzip-dev ldap-utils vim \
&& docker-php-ext-configure ldap \
&& docker-php-ext-install ldap zip \
&& a2enmod rewrite \
&& apt-get clean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
Expand All @@ -46,15 +42,9 @@ RUN { \

WORKDIR /var/www/html

COPY --from=builder --chown=www-data:www-data /build/ .
COPY --from=builder --chown=www-data:www-data /dokuwiki/ /dokuwiki/

RUN ln -s /dokuwiki/conf conf \
&& ln -s /dokuwiki/data data \
&& ln -s /dokuwiki/plugins lib/plugins \
&& ln -s /dokuwiki/tpl lib/tpl \
&& chown -R www-data:www-data . /dokuwiki \
&& a2enmod rewrite
COPY --from=builder /build/ .
RUN mkdir /dokuwiki \
&& chown -R www-data:www-data . /dokuwiki

COPY init-script.sh /usr/local/bin/init-script.sh
RUN chmod +x /usr/local/bin/init-script.sh
Expand Down
30 changes: 27 additions & 3 deletions init-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,38 @@ setup_superadmin() {
[ -n "${DOKUWIKI_SUPERPASS:-}" ] || return 1
[ -n "${DOKUWIKI_FULLNAME:-}" ] || return 1
[ -n "${DOKUWIKI_EMAIL:-}" ] || return 1

grep -q "^\$conf\['superuser'\]" "$LOCAL_FILE" || update_config "superuser" "'@admin'"

local hashed_password=$(php -r "echo password_hash('${DOKUWIKI_SUPERPASS}', PASSWORD_BCRYPT);")
local user_line="${DOKUWIKI_SUPERUSER}:${hashed_password}:${DOKUWIKI_FULLNAME}:${DOKUWIKI_EMAIL}:admin,user"

echo "$user_line" > "$USERS_FILE"
return 0
}

initialize_dokuwiki() {
if [ -z "$(ls -A /dokuwiki)" ]; then
if [ ! -L "/var/www/html/conf" ]; then
mv /var/www/html/conf /dokuwiki/
ln -sf /dokuwiki/conf /var/www/html/conf
fi
if [ ! -L "/var/www/html/data" ]; then
mv /var/www/html/data /dokuwiki/
ln -sf /dokuwiki/data /var/www/html/data
fi
if [ ! -L "/var/www/html/lib/plugins" ]; then
mv /var/www/html/lib/plugins /dokuwiki/plugins
ln -sf /dokuwiki/plugins /var/www/html/lib/plugins
fi
if [ ! -L "/var/www/html/lib/tpl" ]; then
mv /var/www/html/lib/tpl /dokuwiki/tpl
ln -sf /dokuwiki/tpl /var/www/html/lib/tpl
fi
chown -R www-data:www-data /dokuwiki
fi
}

# Main configuration process
if has_dokuwiki_vars; then
process_basic_configs
Expand All @@ -98,4 +120,6 @@ if has_dokuwiki_vars; then
[ -f "$INSTALL_FILE" ] && rm "$INSTALL_FILE"
fi

initialize_dokuwiki

exec apache2-foreground

0 comments on commit 16196ce

Please sign in to comment.