Skip to content

Commit 02a2621

Browse files
f3l1xclaude
andcommitted
All: add MSSQL image variant (#48)
Add Debian-based `adminer-mssql` image with Microsoft ODBC Driver 18 and PHP sqlsrv/pdo_sqlsrv extensions for MS SQL Server support. Includes an `adminer-mssql-encrypt` plugin (enabled by default) that sets TrustServerCertificate=yes so the image works out of the box with self-signed certificates common in development environments. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1cd8122 commit 02a2621

4 files changed

Lines changed: 179 additions & 3 deletions

File tree

.plugins/adminer-mssql-encrypt.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/**
4+
* Configure MSSQL encryption settings via environment variables.
5+
*
6+
* Activated by: ADMINER_PLUGIN_MSSQL_ENCRYPT=1
7+
* Environment variables:
8+
* ADMINER_MSSQL_ENCRYPT - "yes", "no", or "strict" (default: not set)
9+
* ADMINER_MSSQL_TRUST_CERT - "yes" or "no" (default: "yes")
10+
*/
11+
class AdminerMssqlEncrypt extends Adminer\Plugin {
12+
private $ssl;
13+
14+
function __construct() {
15+
$this->ssl = [];
16+
$encrypt = getenv('ADMINER_MSSQL_ENCRYPT');
17+
if ($encrypt !== false) {
18+
$this->ssl['Encrypt'] = $encrypt;
19+
}
20+
$trust = getenv('ADMINER_MSSQL_TRUST_CERT');
21+
$this->ssl['TrustServerCertificate'] = ($trust !== false) ? $trust : 'yes';
22+
}
23+
24+
function connectSsl() {
25+
return $this->ssl;
26+
}
27+
}

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h1 align=center>Dockette / Adminer</h1>
22

33
<p align=center>
4-
🎁 Tiniest boxed dockerized Adminer (MySQL, PostgreSQL, SQLite, Mongo, Oracle) Dockerfiles. Database management in a single PHP file.
4+
🎁 Tiniest boxed dockerized Adminer (MySQL, PostgreSQL, SQLite, Mongo, Oracle, MSSQL) Dockerfiles. Database management in a single PHP file.
55
</p>
66

77
<p align=center>
@@ -26,13 +26,14 @@ There are few variants of this adminer image based:
2626
- mysql (only)
2727
- pgsql (only)
2828
- mongo (only)
29+
- mssql (only)
2930
- oracle-11 / oracle-12 / oracle-19 (only)
3031
- dg (custom)
3132

3233
**Features**
3334

34-
- Alpine Linux (full, editor, df, mongo, mysql, postgres)
35-
- Debian Buster (oracle-11, oracle-12, oracle-19)
35+
- Alpine Linux (full, editor, dg, mongo, mysql, postgres)
36+
- Debian Bookworm (mssql, oracle-11, oracle-12, oracle-19)
3637
- PHP 8 (concurrency via PHP cli workers)
3738

3839
## Usage
@@ -70,8 +71,28 @@ docker run \
7071
| dockette/adminer:mysql | MySQL | 9mb | [link](https://hub.docker.com/r/dockette/adminer/tags/) |
7172
| dockette/adminer:pgsql | PostgreSQL | 8mb | [link](https://hub.docker.com/r/dockette/adminer/tags/) |
7273
| dockette/adminer:mongo | MongoDB | 9mb | [link](https://hub.docker.com/r/dockette/adminer/tags/) |
74+
| dockette/adminer:mssql | MS SQL Server | - | [link](https://hub.docker.com/r/dockette/adminer/tags/) |
7375
| dockette/adminer:dg | MySQL / PostgreSQL / MongoDB / Sqlite | 16mb | [link](https://hub.docker.com/r/dockette/adminer/tags/) |
7476

77+
### `dockette/adminer:mssql`
78+
79+
Debian-based image with Microsoft ODBC Driver 18 and PHP `sqlsrv` / `pdo_sqlsrv` extensions.
80+
81+
```sh
82+
docker run \
83+
--rm \
84+
-p 8080:80 \
85+
dockette/adminer:mssql
86+
```
87+
88+
By default, `TrustServerCertificate` is set to `yes` so the image works out of the box with self-signed certificates (common in development). You can control encryption behavior via environment variables:
89+
90+
| Variable | Description | Default |
91+
|---|---|---|
92+
| `ADMINER_PLUGIN_MSSQL_ENCRYPT` | Set to `0` to disable the encryption plugin | enabled |
93+
| `ADMINER_MSSQL_ENCRYPT` | `yes`, `no`, or `strict` | not set |
94+
| `ADMINER_MSSQL_TRUST_CERT` | `yes` or `no` | `yes` |
95+
7596
### `dockette/adminer:dg`
7697

7798
> Customization for the best database management tool written in PHP, Adminer

adminer-mssql/Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM dockette/debian:bookworm-slim
2+
3+
LABEL maintainer="Milan Sulc <sulcmil@gmail.com>"
4+
5+
ENV ADMINER_VERSION=5.4.2
6+
ENV MEMORY=256M
7+
ENV UPLOAD=2048M
8+
ENV PORT=80
9+
ENV WORKERS=8
10+
ENV PHP_CLI_SERVER_WORKERS=${WORKERS}
11+
12+
# DEPENDENCIES #################################################################
13+
RUN apt-get update && \
14+
apt-get dist-upgrade -y && \
15+
apt install -y apt-transport-https lsb-release ca-certificates curl wget gnupg && \
16+
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
17+
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' && \
18+
apt-get update && \
19+
apt-get install -y \
20+
make \
21+
autoconf \
22+
g++ \
23+
unzip \
24+
ca-certificates \
25+
php8.4 \
26+
php8.4-dev \
27+
php8.4-xml \
28+
php-pear \
29+
tini && \
30+
wget https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.php -O /srv/index.php && \
31+
wget https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.zip -O /tmp/adminer-$ADMINER_VERSION.zip && \
32+
unzip /tmp/adminer-$ADMINER_VERSION.zip -d /tmp && \
33+
mkdir -p /srv/designs && \
34+
mv /tmp/adminer-$ADMINER_VERSION/designs/* /srv/designs/ 2>/dev/null || true && \
35+
rm -rf /tmp/*
36+
37+
# MSSQL (Microsoft ODBC Driver + PHP extensions) ##############################
38+
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && \
39+
echo "deb [signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/debian/12/prod bookworm main" > /etc/apt/sources.list.d/mssql-release.list && \
40+
apt-get update && \
41+
ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev && \
42+
pecl install sqlsrv pdo_sqlsrv && \
43+
echo "extension=sqlsrv.so" > /etc/php/8.4/cli/conf.d/20-sqlsrv.ini && \
44+
echo "extension=pdo_sqlsrv.so" > /etc/php/8.4/cli/conf.d/30-pdo_sqlsrv.ini && \
45+
sed -i 's/^\[ODBC Driver 18 for SQL Server\]$/&\nEncrypt=Optional/' /etc/odbcinst.ini
46+
47+
# CLEAN UP #####################################################################
48+
RUN apt-get clean -y && \
49+
apt-get autoclean -y && \
50+
apt-get remove -y wget make autoconf g++ php8.4-dev php-pear unixodbc-dev && \
51+
apt-get autoremove -y && \
52+
rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/* && \
53+
mkdir -p /srv/adminer-plugins
54+
55+
ADD ./adminer-mssql/entrypoint.sh /entrypoint.sh
56+
ADD ./.plugins/ /srv/plugins-available/
57+
RUN chmod +x /entrypoint.sh
58+
59+
WORKDIR /srv
60+
EXPOSE 80
61+
62+
ENTRYPOINT ["tini", "--"]
63+
CMD ["/entrypoint.sh"]

adminer-mssql/entrypoint.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
set -Eeo pipefail
3+
4+
if [ "${ADMINER_DEBUG}" = "1" ]; then
5+
set -o xtrace
6+
fi
7+
8+
# Banner
9+
if [ "${ADMINER_BANNER}" != "0" ] && [ "${ADMINER_BANNER}" != "false" ] && [ "${ADMINER_BANNER}" != "no" ] && [ "${ADMINER_BANNER}" != "off" ]; then
10+
cat << 'EOF'
11+
█████╗ ██████╗ ███╗ ███╗██╗███╗ ██╗███████╗██████╗
12+
██╔══██╗██╔══██╗████╗ ████║██║████╗ ██║██╔════╝██╔══██╗
13+
███████║██║ ██║██╔████╔██║██║██╔██╗ ██║█████╗ ██████╔╝
14+
██╔══██║██║ ██║██║╚██╔╝██║██║██║╚██╗██║██╔══╝ ██╔══██╗
15+
██║ ██║██████╔╝██║ ╚═╝ ██║██║██║ ╚████║███████╗██║ ██║
16+
╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝
17+
EOF
18+
fi
19+
20+
echo "[adminer] Loading Adminer (MSSQL)..."
21+
22+
# Activate MSSQL encryption plugin (enabled by default for convenience)
23+
if [ "${ADMINER_PLUGIN_MSSQL_ENCRYPT}" != "0" ]; then
24+
cp /srv/plugins-available/adminer-mssql-encrypt.php /srv/adminer-plugins/
25+
echo "[adminer] Plugin 'mssql-encrypt' activated (TrustServerCertificate=${ADMINER_MSSQL_TRUST_CERT:-yes})."
26+
fi
27+
28+
# Copy theme CSS files based on ADMINER_THEME environment variable
29+
if [ -n "${ADMINER_THEME}" ]; then
30+
THEME_DIR="/srv/designs/${ADMINER_THEME}"
31+
if [ -d "${THEME_DIR}" ]; then
32+
if [ -f "${THEME_DIR}/adminer.css" ]; then
33+
cp "${THEME_DIR}/adminer.css" /srv/adminer.css
34+
echo "[adminer] Theme '${ADMINER_THEME}' applied successfully."
35+
else
36+
echo "[adminer] Warning: Theme '${ADMINER_THEME}' does not contain adminer.css"
37+
fi
38+
if [ -f "${THEME_DIR}/adminer-dark.css" ]; then
39+
cp "${THEME_DIR}/adminer-dark.css" /srv/adminer-dark.css
40+
echo "[adminer] Dark mode CSS for theme '${ADMINER_THEME}' applied."
41+
fi
42+
else
43+
echo "[adminer] Warning: Theme '${ADMINER_THEME}' not found in /srv/designs/"
44+
echo "[adminer] Available themes:"
45+
ls -1 /srv/designs/ 2>/dev/null || echo "[adminer] No themes available."
46+
fi
47+
fi
48+
49+
# Set default values if not provided
50+
MEMORY=${MEMORY:-256M}
51+
UPLOAD=${UPLOAD:-2048M}
52+
PORT=${PORT:-80}
53+
54+
echo "[adminer] Starting PHP server (http://0.0.0.0:${PORT} in Docker):"
55+
echo "-> memory_limit=${MEMORY}"
56+
echo "-> upload_max_filesize=${UPLOAD}"
57+
echo "-> post_max_size=${UPLOAD}"
58+
echo "-> port=${PORT}"
59+
60+
# Execute PHP server
61+
exec php \
62+
-d "memory_limit=${MEMORY}" \
63+
-d "upload_max_filesize=${UPLOAD}" \
64+
-d "post_max_size=${UPLOAD}" \
65+
-S "0.0.0.0:${PORT}"

0 commit comments

Comments
 (0)