1
+ # Start from the official DokuWiki image.
2
+ # Using 'latest' or a specific version like '2024-02-06a' is recommended for stability.
3
+ FROM dokuwiki/dokuwiki:latest
4
+
5
+ # Define build argument for the SMTP plugin version.
6
+ # Check https://github.com/splitbrain/dokuwiki-plugin-smtp/releases for the latest stable version.
7
+ ARG SMTP_PLUGIN_VERSION="2023-01-20"
8
+ ARG SMTP_PLUGIN_PATH="https://github.com/splitbrain/dokuwiki-plugin-smtp/zipball/master"
9
+
10
+ # Switch to root user to install system packages and modify configurations.
11
+ USER root
12
+
13
+ # Install necessary dependencies for downloading and extracting the plugin.
14
+ # --no-install-recommends reduces image size by avoiding recommended but not strictly necessary packages.
15
+ RUN apt-get update && \
16
+ apt-get install -y --no-install-recommends \
17
+ curl \
18
+ unzip && \
19
+ rm -rf /var/lib/apt/lists/* # Clean up apt cache to keep image small
20
+
21
+ # --- Apache Port Configuration ---
22
+ # The official DokuWiki image's Apache typically listens on port 80.
23
+ # To align with your Helm charts and previous Dockerfile's EXPOSE 8080,
24
+ # we need to modify Apache's configuration to listen on 8080.
25
+ RUN sed -i 's/^Listen 80/Listen 8080/' /etc/apache2/ports.conf && \
26
+ sed -i 's/<VirtualHost \* :80>/<VirtualHost \* :8080>/' /etc/apache2/sites-available/000-default.conf
27
+
28
+ # --- Healthcheck File ---
29
+ # Based on your previous Dockerfile and Helm probe configurations,
30
+ # it's assumed you have a `health.php` file for readiness/liveness checks.
31
+ # This command copies your local `root/var/www/html/health.php` into the image.
32
+ # Ensure this file exists in your Docker build context.
33
+ COPY root/var/www/html/health.php /var/www/html/health.php
34
+
35
+ # --- DokuWiki SMTP Plugin Installation ---
36
+ # Set the working directory to a temporary location for downloading the plugin.
37
+ WORKDIR /tmp
38
+
39
+ # --- DokuWiki SMTP Plugin Installation ---
40
+ # Set the working directory to a temporary location for downloading and processing.
41
+ # We create a unique temporary directory to avoid conflicts if /tmp contains other files.
42
+ WORKDIR /tmp/dokuwiki_plugin_install
43
+
44
+ # Download the SMTP plugin.
45
+ RUN set -eux; \
46
+ curl -fL -o smtp.zip ${SMTP_PLUGIN_PATH}; \
47
+
48
+ # Unzip the plugin into the current temporary directory.
49
+ # This will create the plugin's root folder (e.g., 'dokuwiki-plugin-smtp-2023-01-20')
50
+ # inside '/tmp/dokuwiki_plugin_install/'.
51
+ RUN set -eux; \
52
+ unzip smtp.zip; \
53
+ # Find the name of the extracted plugin directory.
54
+ # 'find . -maxdepth 1 -mindepth 1 -type d' looks for directories only one level deep.
55
+ # '-print -quit' prints the first one found and exits, assuming there's only one.
56
+ EXTRACTED_DIR=$(find . -maxdepth 1 -mindepth 1 -type d -print -quit); \
57
+ # Move the detected extracted directory to the final 'smtp' location.
58
+ # This directly renames the extracted folder to 'smtp' under /dokuwiki/lib/plugins/
59
+ mv "${EXTRACTED_DIR}" /dokuwiki/lib/plugins/smtp; \
60
+ # Clean up the downloaded zip file and the temporary working directory.
61
+ rm smtp.zip; \
62
+ rm -rf /tmp/dokuwiki_plugin_install # Remove the temporary working directory
63
+
64
+ # ... (rest of the Dockerfile remains the same) ...
65
+
66
+ # --- Permissions for added files and directories ---
67
+ # The official `dokuwiki/dokuwiki` image primarily uses the `www-data` user (UID/GID 33).
68
+ # We must ensure that the `health.php` and the newly installed `smtp` plugin directory
69
+ # are owned by this user so DokuWiki can access and execute them.
70
+ RUN chown www-data:www-data /var/www/html/health.php && \
71
+ chmod +x /var/www/html/health.php && \
72
+ chown -R www-data:www-data /dokuwiki/lib/plugins/smtp
73
+
74
+ # Expose the custom port that Apache is now configured to listen on.
75
+ # This matches the `targetPort` in your Helm service definition.
76
+ EXPOSE 8080
77
+
78
+ # Switch to the non-root user `www-data`.
79
+ # The base image's Dockerfile usually sets this, but it's good practice to be explicit
80
+ # to ensure all subsequent commands (if any) and the container's runtime
81
+ # operate under this non-privileged user.
82
+ USER www-data
83
+
84
+ # The official dokuwiki/dokuwiki image provides its own ENTRYPOINT.
85
+ # We do not need to define one here unless you require custom startup logic
86
+ # that is not handled by the official image's entrypoint.
0 commit comments