Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .plugins/adminer-mssql-encrypt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* Configure MSSQL encryption settings via environment variables.
*
* Activated by: ADMINER_PLUGIN_MSSQL_ENCRYPT=1
* Environment variables:
* ADMINER_MSSQL_ENCRYPT - "yes", "no", or "strict" (default: not set)
* ADMINER_MSSQL_TRUST_CERT - "yes" or "no" (default: "yes")
*/
class AdminerMssqlEncrypt extends Adminer\Plugin {
private $ssl;

function __construct() {
$this->ssl = [];
$encrypt = getenv('ADMINER_MSSQL_ENCRYPT');
if ($encrypt !== false) {
$this->ssl['Encrypt'] = $encrypt;
}
$trust = getenv('ADMINER_MSSQL_TRUST_CERT');
$this->ssl['TrustServerCertificate'] = ($trust !== false) ? $trust : 'yes';
}

function connectSsl() {
return $this->ssl;
}
}
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align=center>Dockette / Adminer</h1>

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

<p align=center>
Expand All @@ -26,13 +26,14 @@ There are few variants of this adminer image based:
- mysql (only)
- pgsql (only)
- mongo (only)
- mssql (only)
- oracle-11 / oracle-12 / oracle-19 (only)
- dg (custom)

**Features**

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

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

### `dockette/adminer:mssql`

Debian-based image with Microsoft ODBC Driver 18 and PHP `sqlsrv` / `pdo_sqlsrv` extensions.

```sh
docker run \
--rm \
-p 8080:80 \
dockette/adminer:mssql
```

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:

| Variable | Description | Default |
|---|---|---|
| `ADMINER_PLUGIN_MSSQL_ENCRYPT` | Set to `0` to disable the encryption plugin | enabled |
| `ADMINER_MSSQL_ENCRYPT` | `yes`, `no`, or `strict` | not set |
| `ADMINER_MSSQL_TRUST_CERT` | `yes` or `no` | `yes` |

### `dockette/adminer:dg`

> Customization for the best database management tool written in PHP, Adminer
Expand Down
63 changes: 63 additions & 0 deletions adminer-mssql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM dockette/debian:bookworm-slim

LABEL maintainer="Milan Sulc <sulcmil@gmail.com>"

ENV ADMINER_VERSION=5.4.2
ENV MEMORY=256M
ENV UPLOAD=2048M
ENV PORT=80
ENV WORKERS=8
ENV PHP_CLI_SERVER_WORKERS=${WORKERS}

# DEPENDENCIES #################################################################
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt install -y apt-transport-https lsb-release ca-certificates curl wget gnupg && \
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' && \
apt-get update && \
apt-get install -y \
make \
autoconf \
g++ \
unzip \
ca-certificates \
php8.4 \
php8.4-dev \
php8.4-xml \
php-pear \
tini && \
wget https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.php -O /srv/index.php && \
wget https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.zip -O /tmp/adminer-$ADMINER_VERSION.zip && \
unzip /tmp/adminer-$ADMINER_VERSION.zip -d /tmp && \
mkdir -p /srv/designs && \
mv /tmp/adminer-$ADMINER_VERSION/designs/* /srv/designs/ 2>/dev/null || true && \
rm -rf /tmp/*

# MSSQL (Microsoft ODBC Driver + PHP extensions) ##############################
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg && \
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 && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev && \
pecl install sqlsrv pdo_sqlsrv && \
echo "extension=sqlsrv.so" > /etc/php/8.4/cli/conf.d/20-sqlsrv.ini && \
echo "extension=pdo_sqlsrv.so" > /etc/php/8.4/cli/conf.d/30-pdo_sqlsrv.ini && \
sed -i 's/^\[ODBC Driver 18 for SQL Server\]$/&\nEncrypt=Optional/' /etc/odbcinst.ini

# CLEAN UP #####################################################################
RUN apt-get clean -y && \
apt-get autoclean -y && \
apt-get remove -y wget make autoconf g++ php8.4-dev php-pear unixodbc-dev && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/* && \
mkdir -p /srv/adminer-plugins

ADD ./adminer-mssql/entrypoint.sh /entrypoint.sh
ADD ./.plugins/ /srv/plugins-available/
RUN chmod +x /entrypoint.sh

WORKDIR /srv
EXPOSE 80

ENTRYPOINT ["tini", "--"]
CMD ["/entrypoint.sh"]
65 changes: 65 additions & 0 deletions adminer-mssql/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
set -Eeo pipefail

if [ "${ADMINER_DEBUG}" = "1" ]; then
set -o xtrace
fi

# Banner
if [ "${ADMINER_BANNER}" != "0" ] && [ "${ADMINER_BANNER}" != "false" ] && [ "${ADMINER_BANNER}" != "no" ] && [ "${ADMINER_BANNER}" != "off" ]; then
cat << 'EOF'
█████╗ ██████╗ ███╗ ███╗██╗███╗ ██╗███████╗██████╗
██╔══██╗██╔══██╗████╗ ████║██║████╗ ██║██╔════╝██╔══██╗
███████║██║ ██║██╔████╔██║██║██╔██╗ ██║█████╗ ██████╔╝
██╔══██║██║ ██║██║╚██╔╝██║██║██║╚██╗██║██╔══╝ ██╔══██╗
██║ ██║██████╔╝██║ ╚═╝ ██║██║██║ ╚████║███████╗██║ ██║
╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝
EOF
fi

echo "[adminer] Loading Adminer (MSSQL)..."

# Activate MSSQL encryption plugin (enabled by default for convenience)
if [ "${ADMINER_PLUGIN_MSSQL_ENCRYPT}" != "0" ]; then
cp /srv/plugins-available/adminer-mssql-encrypt.php /srv/adminer-plugins/
echo "[adminer] Plugin 'mssql-encrypt' activated (TrustServerCertificate=${ADMINER_MSSQL_TRUST_CERT:-yes})."
fi

# Copy theme CSS files based on ADMINER_THEME environment variable
if [ -n "${ADMINER_THEME}" ]; then
THEME_DIR="/srv/designs/${ADMINER_THEME}"
if [ -d "${THEME_DIR}" ]; then
if [ -f "${THEME_DIR}/adminer.css" ]; then
cp "${THEME_DIR}/adminer.css" /srv/adminer.css
echo "[adminer] Theme '${ADMINER_THEME}' applied successfully."
else
echo "[adminer] Warning: Theme '${ADMINER_THEME}' does not contain adminer.css"
fi
if [ -f "${THEME_DIR}/adminer-dark.css" ]; then
cp "${THEME_DIR}/adminer-dark.css" /srv/adminer-dark.css
echo "[adminer] Dark mode CSS for theme '${ADMINER_THEME}' applied."
fi
else
echo "[adminer] Warning: Theme '${ADMINER_THEME}' not found in /srv/designs/"
echo "[adminer] Available themes:"
ls -1 /srv/designs/ 2>/dev/null || echo "[adminer] No themes available."
fi
fi

# Set default values if not provided
MEMORY=${MEMORY:-256M}
UPLOAD=${UPLOAD:-2048M}
PORT=${PORT:-80}

echo "[adminer] Starting PHP server (http://0.0.0.0:${PORT} in Docker):"
echo "-> memory_limit=${MEMORY}"
echo "-> upload_max_filesize=${UPLOAD}"
echo "-> post_max_size=${UPLOAD}"
echo "-> port=${PORT}"

# Execute PHP server
exec php \
-d "memory_limit=${MEMORY}" \
-d "upload_max_filesize=${UPLOAD}" \
-d "post_max_size=${UPLOAD}" \
-S "0.0.0.0:${PORT}"
Loading