mirror of
https://github.com/phpmyadmin/docker.git
synced 2026-08-24 10:13:22 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d26530177 | ||
|
|
5d4b4dec94 | ||
|
|
4f88748138 | ||
|
|
b295aa6bf7 | ||
|
|
dd2ca51984 | ||
|
|
568e58cc53 | ||
|
|
60e766aa9e | ||
|
|
05d5c516d3 | ||
|
|
2576eb2c26 | ||
|
|
bf6422b6a6 | ||
|
|
8edcc52dfb | ||
|
|
ed101c2f39 | ||
|
|
fb5222a52c | ||
|
|
d147a455af | ||
|
|
4e2998a2c5 | ||
|
|
44ab81b7cf | ||
|
|
4b236d823a | ||
|
|
1eede2e6b4 | ||
|
|
7cd2b5b46f | ||
|
|
62b73c11a9 | ||
|
|
a309c96f6a | ||
|
|
78f64ee5ce | ||
|
|
2313c19aed | ||
|
|
7d8a3e5717 | ||
|
|
b696c1f43d | ||
|
|
53a793568a | ||
|
|
43888414d6 | ||
|
|
0343ca5338 |
@@ -0,0 +1 @@
|
||||
*.sql linguist-detectable=false
|
||||
@@ -1 +1,6 @@
|
||||
config.secret.inc.php
|
||||
__pycache__
|
||||
.pytest_cache
|
||||
.vscode
|
||||
.history
|
||||
.venv
|
||||
+1
-1
@@ -15,7 +15,7 @@ before_install:
|
||||
- docker run --name db_server -e MYSQL_ROOT_PASSWORD=$TESTSUITE_PASSWORD -v $PWD/testing/testing.cnf:/etc/mysql/conf.d/testing.cnf:ro -d $DB
|
||||
|
||||
install:
|
||||
- pip install mechanize html5lib
|
||||
- pip install mechanize html5lib pytest
|
||||
|
||||
_helpers:
|
||||
- &test-docker-compose
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM php:7.2-%%VARIANT%%
|
||||
FROM php:7.4-%%VARIANT%%
|
||||
|
||||
# docker-entrypoint.sh dependencies
|
||||
RUN apk add --no-cache \
|
||||
@@ -14,10 +14,17 @@ RUN set -ex; \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
libxpm-dev \
|
||||
libzip-dev \
|
||||
; \
|
||||
\
|
||||
docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-webp-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr; \
|
||||
docker-php-ext-install bz2 gd mysqli opcache zip; \
|
||||
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm; \
|
||||
docker-php-ext-install -j "$(nproc)" \
|
||||
bz2 \
|
||||
gd \
|
||||
mysqli \
|
||||
opcache \
|
||||
zip \
|
||||
; \
|
||||
\
|
||||
runDeps="$( \
|
||||
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
|
||||
@@ -36,19 +43,18 @@ RUN { \
|
||||
echo 'opcache.max_accelerated_files=4000'; \
|
||||
echo 'opcache.revalidate_freq=2'; \
|
||||
echo 'opcache.fast_shutdown=1'; \
|
||||
echo 'opcache.enable_cli=1'; \
|
||||
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/opcache-recommended.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'session.cookie_httponly = 1'; \
|
||||
echo 'session.use_strict_mode = 1'; \
|
||||
} > /usr/local/etc/php/conf.d/session-strict.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/session-strict.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'allow_url_fopen = Off'; \
|
||||
echo 'max_execution_time = 600'; \
|
||||
echo 'memory_limit = 512M'; \
|
||||
} > /usr/local/etc/php/conf.d/phpmyadmin-misc.ini
|
||||
} > $PHP_INI_DIR/conf.d/phpmyadmin-misc.ini
|
||||
|
||||
# Calculate download URL
|
||||
ENV VERSION %%VERSION%%
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM php:7.2-%%VARIANT%%
|
||||
FROM php:7.4-%%VARIANT%%
|
||||
|
||||
# Install dependencies
|
||||
RUN set -ex; \
|
||||
@@ -13,10 +13,17 @@ RUN set -ex; \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
libxpm-dev \
|
||||
libzip-dev \
|
||||
; \
|
||||
\
|
||||
docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-webp-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr; \
|
||||
docker-php-ext-install bz2 gd mysqli opcache zip; \
|
||||
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm; \
|
||||
docker-php-ext-install -j "$(nproc)" \
|
||||
bz2 \
|
||||
gd \
|
||||
mysqli \
|
||||
opcache \
|
||||
zip \
|
||||
; \
|
||||
\
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
apt-mark manual $savedAptMark; \
|
||||
@@ -39,19 +46,18 @@ RUN { \
|
||||
echo 'opcache.max_accelerated_files=4000'; \
|
||||
echo 'opcache.revalidate_freq=2'; \
|
||||
echo 'opcache.fast_shutdown=1'; \
|
||||
echo 'opcache.enable_cli=1'; \
|
||||
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/opcache-recommended.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'session.cookie_httponly = 1'; \
|
||||
echo 'session.use_strict_mode = 1'; \
|
||||
} > /usr/local/etc/php/conf.d/session-strict.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/session-strict.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'allow_url_fopen = Off'; \
|
||||
echo 'max_execution_time = 600'; \
|
||||
echo 'memory_limit = 512M'; \
|
||||
} > /usr/local/etc/php/conf.d/phpmyadmin-misc.ini
|
||||
} > $PHP_INI_DIR/conf.d/phpmyadmin-misc.ini
|
||||
|
||||
# Calculate download URL
|
||||
ENV VERSION %%VERSION%%
|
||||
|
||||
@@ -18,6 +18,9 @@ build-fpm-alpine:
|
||||
run:
|
||||
docker-compose -f docker-compose.testing.yml up -d
|
||||
|
||||
run-tests:
|
||||
docker-compose exec phpmyadmin /test-docker.sh phpmyadmin_testing 80 phpmyadmin_testing_db
|
||||
|
||||
logs:
|
||||
docker-compose -f docker-compose.testing.yml logs
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Official phpMyAdmin Docker image
|
||||
|
||||
Run phpMyAdmin with Alpine, supervisor, nginx and PHP FPM.
|
||||
Run phpMyAdmin with Alpine, Apache and PHP FPM.
|
||||
|
||||
[](https://travis-ci.org/phpmyadmin/docker)
|
||||
[][hub]
|
||||
@@ -22,27 +22,29 @@ The official MySQL and MariaDB use following environment variables to define the
|
||||
* `MYSQL_ROOT_PASSWORD` - This variable is mandatory and specifies the password that will be set for the `root` superuser account.
|
||||
* `MYSQL_USER`, `MYSQL_PASSWORD` - These variables are optional, used in conjunction to create a new user and to set that user's password.
|
||||
|
||||
## Docker hub tags
|
||||
## Supported Docker hub tags
|
||||
|
||||
You can use following tags on Docker hub:
|
||||
The following tags are available:
|
||||
|
||||
* `latest` - latest stable release
|
||||
* `4.8` - latest stable release for the 4.8 version
|
||||
* `4.8.5` - specific patch release for the 4.8 version
|
||||
* `latest`, `fpm`, and `fpm-alpine` are always the most recent released version
|
||||
* Major versions, such as `5`, `5-fpm`, and `5-fpm-alpine`
|
||||
* Specific minor versions, such as `5.0`, `5.0-fpm`, and `5-fpm-alpine`
|
||||
* Specific patch versions, such as `5.0.0`, `5.0.0-fpm`, and `5.0.0-alpine`. Note that, on rare occasion,
|
||||
there may be an intermediary "docker-only" release, such as 4.9.2-1
|
||||
* `edge`, `edge-fpm`, `edge-fpm-alpine`, a development version build from the daily snapshot
|
||||
|
||||
For each tag the following variants are provided:
|
||||
A complete list of tags is [available at Docker Hub](https://hub.docker.com/r/phpmyadmin/phpmyadmin/tags)
|
||||
|
||||
### apache
|
||||
## Image variants
|
||||
|
||||
This starts an Apache webserver with PHP, so you can use phpMyAdmin out of the box.
|
||||
We provide three variations:
|
||||
|
||||
### fpm-alpine
|
||||
|
||||
This image has a very small footprint. It is based on Alpine Linux and starts only a PHP FPM process. Use this variant if you already have a seperate webserver. If you need more tools, that are not available on Alpine Linux, use the fpm image instead.
|
||||
|
||||
### fpm
|
||||
|
||||
This image starts only a PHP FPM container. Use this variant if you already have a seperate webserver.
|
||||
* "apache" includes a full Apache webserver with PHP and includes everything needed to work out of the box.
|
||||
This is the default when only a version number is requested.
|
||||
* "fpm" only starts a PHP FPM container. Use this variant if you already have a seperate webserver.
|
||||
This includes more tools and is therefore a larger image than the "fpm-alpine" variation.
|
||||
* "fpm-alpine" has a very small footprint. It is based on Alpine Linux and only starts a PHP FPM process.
|
||||
Use this variant if you already have a seperate webserver. If you need more tools that are not available on Alpine Linux, use the fpm image instead.
|
||||
|
||||
## Usage with linked server
|
||||
|
||||
@@ -93,15 +95,15 @@ docker-compose -f docker-compose.testing.yml up phpmyadmin
|
||||
|
||||
## Adding Custom Configuration
|
||||
|
||||
You can add your own custom config.inc.php settings (such as Configuration Storage setup)
|
||||
by creating a file named "config.user.inc.php" with the various user defined settings
|
||||
You can add your own custom config.inc.php settings (such as Configuration Storage setup)
|
||||
by creating a file named "config.user.inc.php" with the various user defined settings
|
||||
in it, and then linking it into the container using:
|
||||
|
||||
```
|
||||
-v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
|
||||
```
|
||||
On the "docker run" line like this:
|
||||
```
|
||||
```
|
||||
docker run --name myadmin -d --link mysql_db_server:db -p 8080:80 -v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php phpmyadmin/phpmyadmin
|
||||
```
|
||||
|
||||
@@ -124,14 +126,27 @@ Set the variable ``PMA_ABSOLUTE_URI`` to the fully-qualified path (``https://pma
|
||||
* ``PMA_PORTS`` - define comma separated list of ports of the MySQL servers
|
||||
* ``PMA_USER`` and ``PMA_PASSWORD`` - define username to use for config authentication method
|
||||
* ``PMA_ABSOLUTE_URI`` - define user-facing URI
|
||||
* ``HIDE_PHP_VERSION`` - if defined, will hide the php version (`expose_php = Off`). Set to any value (such as HIDE_PHP_VERSION=true).
|
||||
* ``UPLOAD_LIMIT`` - if set, will override the default value for apache and php-fpm (default value is 2048 kb)
|
||||
* ``PMA_CONFIG_BASE64`` - if set, will override the default config.inc.php with the base64 decoded contents of the variable
|
||||
* ``PMA_USER_CONFIG_BASE64`` - if set, will override the default config.user.inc.php with the base64 decoded contents of the variable
|
||||
|
||||
For usage with Docker secrets, appending ``_FILE`` to any environment variable is allowed:
|
||||
For usage with Docker secrets, appending ``_FILE`` to the ``PMA_PASSWORD`` environment variable is allowed (it overrides ``PMA_PASSWORD`` if it is set):
|
||||
```
|
||||
docker run --name myadmin -d -e PMA_PASSWORD_FILE=/run/secrets/db_password.txt -p 8080:80 phpmyadmin/phpmyadmin
|
||||
```
|
||||
|
||||
#### Variables that can be read from a file using ``_FILE``
|
||||
- PMA_PASSWORD
|
||||
- MYSQL_ROOT_PASSWORD
|
||||
- MYSQL_PASSWORD
|
||||
- PMA_HOSTS
|
||||
- PMA_HOST
|
||||
|
||||
For more detailed documentation see https://docs.phpmyadmin.net/en/latest/setup.html#installing-using-docker
|
||||
|
||||
[hub]: https://hub.docker.com/r/phpmyadmin/phpmyadmin/
|
||||
|
||||
Please report any issues with the Docker container to https://github.com/phpmyadmin/docker/issues
|
||||
|
||||
Please report any issues with phpMyAdmin to https://github.com/phpmyadmin/phpmyadmin/issues
|
||||
|
||||
+14
-8
@@ -1,4 +1,4 @@
|
||||
FROM php:7.2-apache
|
||||
FROM php:7.4-apache
|
||||
|
||||
# Install dependencies
|
||||
RUN set -ex; \
|
||||
@@ -13,10 +13,17 @@ RUN set -ex; \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
libxpm-dev \
|
||||
libzip-dev \
|
||||
; \
|
||||
\
|
||||
docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-webp-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr; \
|
||||
docker-php-ext-install bz2 gd mysqli opcache zip; \
|
||||
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm; \
|
||||
docker-php-ext-install -j "$(nproc)" \
|
||||
bz2 \
|
||||
gd \
|
||||
mysqli \
|
||||
opcache \
|
||||
zip \
|
||||
; \
|
||||
\
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
apt-mark manual $savedAptMark; \
|
||||
@@ -39,22 +46,21 @@ RUN { \
|
||||
echo 'opcache.max_accelerated_files=4000'; \
|
||||
echo 'opcache.revalidate_freq=2'; \
|
||||
echo 'opcache.fast_shutdown=1'; \
|
||||
echo 'opcache.enable_cli=1'; \
|
||||
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/opcache-recommended.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'session.cookie_httponly = 1'; \
|
||||
echo 'session.use_strict_mode = 1'; \
|
||||
} > /usr/local/etc/php/conf.d/session-strict.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/session-strict.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'allow_url_fopen = Off'; \
|
||||
echo 'max_execution_time = 600'; \
|
||||
echo 'memory_limit = 512M'; \
|
||||
} > /usr/local/etc/php/conf.d/phpmyadmin-misc.ini
|
||||
} > $PHP_INI_DIR/conf.d/phpmyadmin-misc.ini
|
||||
|
||||
# Calculate download URL
|
||||
ENV VERSION 4.9.1
|
||||
ENV VERSION 5.0.0
|
||||
ENV URL https://files.phpmyadmin.net/phpMyAdmin/${VERSION}/phpMyAdmin-${VERSION}-all-languages.tar.xz
|
||||
LABEL version=$VERSION
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
||||
group="$(id -g)"
|
||||
fi
|
||||
|
||||
chown www-data:www-data /sessions /var/nginx/client_body_temp
|
||||
# Custom folders for sessions
|
||||
chown ${user}:${group} /sessions /var/nginx/client_body_temp
|
||||
|
||||
if ! [ -e index.php -a -e db_designer.php ]; then
|
||||
if ! [ -e index.php -a -e url.php ]; then
|
||||
echo >&2 "phpMyAdmin not found in $PWD - copying now..."
|
||||
if [ "$(ls -A)" ]; then
|
||||
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
|
||||
@@ -47,4 +48,43 @@ EOT
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${HIDE_PHP_VERSION}" ]; then
|
||||
echo "PHP version is now hidden."
|
||||
echo -e 'expose_php = Off\n' > $PHP_INI_DIR/conf.d/phpmyadmin-hide-php-version.ini
|
||||
fi
|
||||
|
||||
UPLOAD_LIMIT_INI_FILE="$PHP_INI_DIR/conf.d/phpmyadmin-upload-limit.ini"
|
||||
if [ ! -z "${UPLOAD_LIMIT}" ]; then
|
||||
echo "Adding the custom upload limit."
|
||||
echo -e "upload_max_filesize = $UPLOAD_LIMIT\npost_max_size = $UPLOAD_LIMIT\n" > $UPLOAD_LIMIT_INI_FILE
|
||||
fi
|
||||
|
||||
if [ ! -z "${PMA_CONFIG_BASE64}" ]; then
|
||||
echo "Adding the custom config.inc.php from base64."
|
||||
echo "${PMA_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.inc.php
|
||||
fi
|
||||
|
||||
if [ ! -z "${PMA_USER_CONFIG_BASE64}" ]; then
|
||||
echo "Adding the custom config.user.inc.php from base64."
|
||||
echo "${PMA_USER_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.user.inc.php
|
||||
fi
|
||||
|
||||
function get_docker_secret() {
|
||||
local env_var="${1}"
|
||||
local env_var_file="${env_var}_FILE"
|
||||
|
||||
# Check if the variable with name $env_var_file (which is $PMA_PASSWORD_FILE for example)
|
||||
# is not empty and export $PMA_PASSWORD as the password in the Docker secrets file
|
||||
|
||||
if [[ -n "${!env_var_file}" ]]; then
|
||||
export "${env_var}"="$(cat "${!env_var_file}")"
|
||||
fi
|
||||
}
|
||||
|
||||
get_docker_secret PMA_PASSWORD
|
||||
get_docker_secret MYSQL_ROOT_PASSWORD
|
||||
get_docker_secret MYSQL_PASSWORD
|
||||
get_docker_secret PMA_HOSTS
|
||||
get_docker_secret PMA_HOST
|
||||
|
||||
exec "$@"
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
version: '2'
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
db_server:
|
||||
image: ${DB}
|
||||
image: ${DB:-mariadb:10.3}
|
||||
container_name: phpmyadmin_testing_db
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=${TESTSUITE_PASSWORD}
|
||||
- MYSQL_ROOT_PASSWORD=${TESTSUITE_PASSWORD:-my-secret-pw}
|
||||
volumes:
|
||||
- ./testing/testing.cnf:/etc/mysql/conf.d/testing.cnf:ro
|
||||
tmpfs:
|
||||
- /var/lib/mysql:rw,noexec,nosuid,size=300m
|
||||
|
||||
phpmyadmin:
|
||||
build:
|
||||
context: testing/
|
||||
links:
|
||||
- db_server:db_server
|
||||
container_name: phpmyadmin_testing
|
||||
volumes:
|
||||
- /sessions
|
||||
- ./testing/conftest.py:/conftest.py
|
||||
- ./testing/test-docker.sh:/test-docker.sh
|
||||
- ./testing/phpmyadmin_test.py:/phpmyadmin_test.py
|
||||
- ./docker-entrypoint.sh:/docker-entrypoint.sh
|
||||
ports:
|
||||
- 8090:80
|
||||
environment:
|
||||
- PMA_ARBITRARY=1
|
||||
- TESTSUITE_PASSWORD=${TESTSUITE_PASSWORD}
|
||||
- TESTSUITE_PASSWORD=${TESTSUITE_PASSWORD:-my-secret-pw}
|
||||
depends_on:
|
||||
- db_server
|
||||
|
||||
+42
-2
@@ -16,9 +16,10 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
||||
group="$(id -g)"
|
||||
fi
|
||||
|
||||
chown www-data:www-data /sessions /var/nginx/client_body_temp
|
||||
# Custom folders for sessions
|
||||
chown ${user}:${group} /sessions /var/nginx/client_body_temp
|
||||
|
||||
if ! [ -e index.php -a -e db_designer.php ]; then
|
||||
if ! [ -e index.php -a -e url.php ]; then
|
||||
echo >&2 "phpMyAdmin not found in $PWD - copying now..."
|
||||
if [ "$(ls -A)" ]; then
|
||||
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
|
||||
@@ -47,4 +48,43 @@ EOT
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${HIDE_PHP_VERSION}" ]; then
|
||||
echo "PHP version is now hidden."
|
||||
echo -e 'expose_php = Off\n' > $PHP_INI_DIR/conf.d/phpmyadmin-hide-php-version.ini
|
||||
fi
|
||||
|
||||
UPLOAD_LIMIT_INI_FILE="$PHP_INI_DIR/conf.d/phpmyadmin-upload-limit.ini"
|
||||
if [ ! -z "${UPLOAD_LIMIT}" ]; then
|
||||
echo "Adding the custom upload limit."
|
||||
echo -e "upload_max_filesize = $UPLOAD_LIMIT\npost_max_size = $UPLOAD_LIMIT\n" > $UPLOAD_LIMIT_INI_FILE
|
||||
fi
|
||||
|
||||
if [ ! -z "${PMA_CONFIG_BASE64}" ]; then
|
||||
echo "Adding the custom config.inc.php from base64."
|
||||
echo "${PMA_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.inc.php
|
||||
fi
|
||||
|
||||
if [ ! -z "${PMA_USER_CONFIG_BASE64}" ]; then
|
||||
echo "Adding the custom config.user.inc.php from base64."
|
||||
echo "${PMA_USER_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.user.inc.php
|
||||
fi
|
||||
|
||||
function get_docker_secret() {
|
||||
local env_var="${1}"
|
||||
local env_var_file="${env_var}_FILE"
|
||||
|
||||
# Check if the variable with name $env_var_file (which is $PMA_PASSWORD_FILE for example)
|
||||
# is not empty and export $PMA_PASSWORD as the password in the Docker secrets file
|
||||
|
||||
if [[ -n "${!env_var_file}" ]]; then
|
||||
export "${env_var}"="$(cat "${!env_var_file}")"
|
||||
fi
|
||||
}
|
||||
|
||||
get_docker_secret PMA_PASSWORD
|
||||
get_docker_secret MYSQL_ROOT_PASSWORD
|
||||
get_docker_secret MYSQL_PASSWORD
|
||||
get_docker_secret PMA_HOSTS
|
||||
get_docker_secret PMA_HOST
|
||||
|
||||
exec "$@"
|
||||
|
||||
+14
-8
@@ -1,4 +1,4 @@
|
||||
FROM php:7.2-fpm-alpine
|
||||
FROM php:7.4-fpm-alpine
|
||||
|
||||
# docker-entrypoint.sh dependencies
|
||||
RUN apk add --no-cache \
|
||||
@@ -14,10 +14,17 @@ RUN set -ex; \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
libxpm-dev \
|
||||
libzip-dev \
|
||||
; \
|
||||
\
|
||||
docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-webp-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr; \
|
||||
docker-php-ext-install bz2 gd mysqli opcache zip; \
|
||||
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm; \
|
||||
docker-php-ext-install -j "$(nproc)" \
|
||||
bz2 \
|
||||
gd \
|
||||
mysqli \
|
||||
opcache \
|
||||
zip \
|
||||
; \
|
||||
\
|
||||
runDeps="$( \
|
||||
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
|
||||
@@ -36,22 +43,21 @@ RUN { \
|
||||
echo 'opcache.max_accelerated_files=4000'; \
|
||||
echo 'opcache.revalidate_freq=2'; \
|
||||
echo 'opcache.fast_shutdown=1'; \
|
||||
echo 'opcache.enable_cli=1'; \
|
||||
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/opcache-recommended.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'session.cookie_httponly = 1'; \
|
||||
echo 'session.use_strict_mode = 1'; \
|
||||
} > /usr/local/etc/php/conf.d/session-strict.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/session-strict.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'allow_url_fopen = Off'; \
|
||||
echo 'max_execution_time = 600'; \
|
||||
echo 'memory_limit = 512M'; \
|
||||
} > /usr/local/etc/php/conf.d/phpmyadmin-misc.ini
|
||||
} > $PHP_INI_DIR/conf.d/phpmyadmin-misc.ini
|
||||
|
||||
# Calculate download URL
|
||||
ENV VERSION 4.9.1
|
||||
ENV VERSION 5.0.0
|
||||
ENV URL https://files.phpmyadmin.net/phpMyAdmin/${VERSION}/phpMyAdmin-${VERSION}-all-languages.tar.xz
|
||||
LABEL version=$VERSION
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
||||
group="$(id -g)"
|
||||
fi
|
||||
|
||||
chown www-data:www-data /sessions /var/nginx/client_body_temp
|
||||
# Custom folders for sessions
|
||||
chown ${user}:${group} /sessions /var/nginx/client_body_temp
|
||||
|
||||
if ! [ -e index.php -a -e db_designer.php ]; then
|
||||
if ! [ -e index.php -a -e url.php ]; then
|
||||
echo >&2 "phpMyAdmin not found in $PWD - copying now..."
|
||||
if [ "$(ls -A)" ]; then
|
||||
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
|
||||
@@ -47,4 +48,43 @@ EOT
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${HIDE_PHP_VERSION}" ]; then
|
||||
echo "PHP version is now hidden."
|
||||
echo -e 'expose_php = Off\n' > $PHP_INI_DIR/conf.d/phpmyadmin-hide-php-version.ini
|
||||
fi
|
||||
|
||||
UPLOAD_LIMIT_INI_FILE="$PHP_INI_DIR/conf.d/phpmyadmin-upload-limit.ini"
|
||||
if [ ! -z "${UPLOAD_LIMIT}" ]; then
|
||||
echo "Adding the custom upload limit."
|
||||
echo -e "upload_max_filesize = $UPLOAD_LIMIT\npost_max_size = $UPLOAD_LIMIT\n" > $UPLOAD_LIMIT_INI_FILE
|
||||
fi
|
||||
|
||||
if [ ! -z "${PMA_CONFIG_BASE64}" ]; then
|
||||
echo "Adding the custom config.inc.php from base64."
|
||||
echo "${PMA_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.inc.php
|
||||
fi
|
||||
|
||||
if [ ! -z "${PMA_USER_CONFIG_BASE64}" ]; then
|
||||
echo "Adding the custom config.user.inc.php from base64."
|
||||
echo "${PMA_USER_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.user.inc.php
|
||||
fi
|
||||
|
||||
function get_docker_secret() {
|
||||
local env_var="${1}"
|
||||
local env_var_file="${env_var}_FILE"
|
||||
|
||||
# Check if the variable with name $env_var_file (which is $PMA_PASSWORD_FILE for example)
|
||||
# is not empty and export $PMA_PASSWORD as the password in the Docker secrets file
|
||||
|
||||
if [[ -n "${!env_var_file}" ]]; then
|
||||
export "${env_var}"="$(cat "${!env_var_file}")"
|
||||
fi
|
||||
}
|
||||
|
||||
get_docker_secret PMA_PASSWORD
|
||||
get_docker_secret MYSQL_ROOT_PASSWORD
|
||||
get_docker_secret MYSQL_PASSWORD
|
||||
get_docker_secret PMA_HOSTS
|
||||
get_docker_secret PMA_HOST
|
||||
|
||||
exec "$@"
|
||||
|
||||
+14
-8
@@ -1,4 +1,4 @@
|
||||
FROM php:7.2-fpm
|
||||
FROM php:7.4-fpm
|
||||
|
||||
# Install dependencies
|
||||
RUN set -ex; \
|
||||
@@ -13,10 +13,17 @@ RUN set -ex; \
|
||||
libpng-dev \
|
||||
libwebp-dev \
|
||||
libxpm-dev \
|
||||
libzip-dev \
|
||||
; \
|
||||
\
|
||||
docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-webp-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr; \
|
||||
docker-php-ext-install bz2 gd mysqli opcache zip; \
|
||||
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm; \
|
||||
docker-php-ext-install -j "$(nproc)" \
|
||||
bz2 \
|
||||
gd \
|
||||
mysqli \
|
||||
opcache \
|
||||
zip \
|
||||
; \
|
||||
\
|
||||
apt-mark auto '.*' > /dev/null; \
|
||||
apt-mark manual $savedAptMark; \
|
||||
@@ -39,22 +46,21 @@ RUN { \
|
||||
echo 'opcache.max_accelerated_files=4000'; \
|
||||
echo 'opcache.revalidate_freq=2'; \
|
||||
echo 'opcache.fast_shutdown=1'; \
|
||||
echo 'opcache.enable_cli=1'; \
|
||||
} > /usr/local/etc/php/conf.d/opcache-recommended.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/opcache-recommended.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'session.cookie_httponly = 1'; \
|
||||
echo 'session.use_strict_mode = 1'; \
|
||||
} > /usr/local/etc/php/conf.d/session-strict.ini; \
|
||||
} > $PHP_INI_DIR/conf.d/session-strict.ini; \
|
||||
\
|
||||
{ \
|
||||
echo 'allow_url_fopen = Off'; \
|
||||
echo 'max_execution_time = 600'; \
|
||||
echo 'memory_limit = 512M'; \
|
||||
} > /usr/local/etc/php/conf.d/phpmyadmin-misc.ini
|
||||
} > $PHP_INI_DIR/conf.d/phpmyadmin-misc.ini
|
||||
|
||||
# Calculate download URL
|
||||
ENV VERSION 4.9.1
|
||||
ENV VERSION 5.0.0
|
||||
ENV URL https://files.phpmyadmin.net/phpMyAdmin/${VERSION}/phpMyAdmin-${VERSION}-all-languages.tar.xz
|
||||
LABEL version=$VERSION
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
||||
group="$(id -g)"
|
||||
fi
|
||||
|
||||
chown www-data:www-data /sessions /var/nginx/client_body_temp
|
||||
# Custom folders for sessions
|
||||
chown ${user}:${group} /sessions /var/nginx/client_body_temp
|
||||
|
||||
if ! [ -e index.php -a -e db_designer.php ]; then
|
||||
if ! [ -e index.php -a -e url.php ]; then
|
||||
echo >&2 "phpMyAdmin not found in $PWD - copying now..."
|
||||
if [ "$(ls -A)" ]; then
|
||||
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
|
||||
@@ -47,4 +48,43 @@ EOT
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${HIDE_PHP_VERSION}" ]; then
|
||||
echo "PHP version is now hidden."
|
||||
echo -e 'expose_php = Off\n' > $PHP_INI_DIR/conf.d/phpmyadmin-hide-php-version.ini
|
||||
fi
|
||||
|
||||
UPLOAD_LIMIT_INI_FILE="$PHP_INI_DIR/conf.d/phpmyadmin-upload-limit.ini"
|
||||
if [ ! -z "${UPLOAD_LIMIT}" ]; then
|
||||
echo "Adding the custom upload limit."
|
||||
echo -e "upload_max_filesize = $UPLOAD_LIMIT\npost_max_size = $UPLOAD_LIMIT\n" > $UPLOAD_LIMIT_INI_FILE
|
||||
fi
|
||||
|
||||
if [ ! -z "${PMA_CONFIG_BASE64}" ]; then
|
||||
echo "Adding the custom config.inc.php from base64."
|
||||
echo "${PMA_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.inc.php
|
||||
fi
|
||||
|
||||
if [ ! -z "${PMA_USER_CONFIG_BASE64}" ]; then
|
||||
echo "Adding the custom config.user.inc.php from base64."
|
||||
echo "${PMA_USER_CONFIG_BASE64}" | base64 -d > /etc/phpmyadmin/config.user.inc.php
|
||||
fi
|
||||
|
||||
function get_docker_secret() {
|
||||
local env_var="${1}"
|
||||
local env_var_file="${env_var}_FILE"
|
||||
|
||||
# Check if the variable with name $env_var_file (which is $PMA_PASSWORD_FILE for example)
|
||||
# is not empty and export $PMA_PASSWORD as the password in the Docker secrets file
|
||||
|
||||
if [[ -n "${!env_var_file}" ]]; then
|
||||
export "${env_var}"="$(cat "${!env_var_file}")"
|
||||
fi
|
||||
}
|
||||
|
||||
get_docker_secret PMA_PASSWORD
|
||||
get_docker_secret MYSQL_ROOT_PASSWORD
|
||||
get_docker_secret MYSQL_PASSWORD
|
||||
get_docker_secret PMA_HOSTS
|
||||
get_docker_secret PMA_HOST
|
||||
|
||||
exec "$@"
|
||||
|
||||
+3
-2
@@ -10,7 +10,8 @@ RUN set -ex; \
|
||||
curl \
|
||||
python-pip \
|
||||
; \
|
||||
pip install mechanize html5lib; \
|
||||
pip install setuptools wheel; \
|
||||
pip install mechanize html5lib pytest; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY phpmyadmin_test.py test-docker.sh world.sql /
|
||||
COPY phpmyadmin_test.py test-docker.sh world.sql conftest.py /
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption("--url")
|
||||
parser.addoption("--username")
|
||||
parser.addoption("--password")
|
||||
parser.addoption("--server")
|
||||
parser.addoption("--sqlfile")
|
||||
|
||||
@pytest.fixture
|
||||
def url(request):
|
||||
return request.config.getoption("--url")
|
||||
|
||||
@pytest.fixture
|
||||
def username(request):
|
||||
return request.config.getoption("--username")
|
||||
|
||||
@pytest.fixture
|
||||
def password(request):
|
||||
return request.config.getoption("--password")
|
||||
|
||||
@pytest.fixture
|
||||
def server(request):
|
||||
return request.config.getoption("--server")
|
||||
|
||||
@pytest.fixture
|
||||
def sqlfile(request):
|
||||
return request.config.getoption("--sqlfile")
|
||||
+31
-27
@@ -1,26 +1,27 @@
|
||||
#!/usr/bin/env python2
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import re
|
||||
import sys
|
||||
|
||||
import mechanize
|
||||
import tempfile
|
||||
import pytest
|
||||
|
||||
|
||||
def test_content(match, content):
|
||||
if not match in content:
|
||||
print(content)
|
||||
raise Exception('{0} not found in content!'.format(match))
|
||||
def do_test_content(match, content):
|
||||
assert(match in content)
|
||||
|
||||
|
||||
def test_phpmyadmin(url, username, password, server=None, sqlfile=None):
|
||||
def test_phpmyadmin(url, username, password, server, sqlfile):
|
||||
if sqlfile is None:
|
||||
if os.path.exists('/world.sql'):
|
||||
sqlfile = '/world.sql'
|
||||
elif os.path.exists('./world.sql'):
|
||||
sqlfile = './world.sql'
|
||||
else:
|
||||
sqlfile = './testing/world.sql'
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
sqlfile = path + '/world.sql'
|
||||
br = mechanize.Browser()
|
||||
|
||||
# Ignore robots.txt
|
||||
@@ -38,36 +39,39 @@ def test_phpmyadmin(url, username, password, server=None, sqlfile=None):
|
||||
|
||||
# Login and check if loggged in
|
||||
response = br.submit()
|
||||
test_content('Server version', response.read())
|
||||
do_test_content('Server version', response.read())
|
||||
|
||||
# Open server import
|
||||
response = br.follow_link(text_regex=re.compile('Import'))
|
||||
test_content('OpenDocument Spreadsheet', response.read())
|
||||
do_test_content('OpenDocument Spreadsheet', response.read())
|
||||
|
||||
# Upload SQL file
|
||||
br.select_form('import')
|
||||
br.form.add_file(open(sqlfile), 'text/plain', sqlfile)
|
||||
response = br.submit()
|
||||
test_content('5326 queries executed', response.read())
|
||||
do_test_content('5326 queries executed', response.read())
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--url', required=True)
|
||||
parser.add_argument('--username', required=True)
|
||||
parser.add_argument('--password', required=True)
|
||||
parser.add_argument('--server')
|
||||
parser.add_argument('--sqlfile', default=None)
|
||||
args = parser.parse_args()
|
||||
def docker_secret(env_name):
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
secret_file = tempfile.mkstemp()
|
||||
|
||||
test_phpmyadmin(
|
||||
args.url,
|
||||
args.username,
|
||||
args.password,
|
||||
args.server,
|
||||
args.sqlfile
|
||||
)
|
||||
password = "The_super_secret_password"
|
||||
password_file = open(secret_file[1], 'wb')
|
||||
password_file.write(str.encode(password))
|
||||
password_file.close()
|
||||
|
||||
test_env = {env_name + '_FILE': secret_file[1]}
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
# Run entrypoint and afterwards echo the environment variables
|
||||
result = subprocess.Popen(dir_path+ "/../docker-entrypoint.sh 'env'", shell=True, stdout=subprocess.PIPE, env=test_env)
|
||||
output = result.stdout.read().decode()
|
||||
|
||||
assert (env_name + "=" + password) in output
|
||||
|
||||
def test_phpmyadmin_secrets():
|
||||
docker_secret('MYSQL_PASSWORD')
|
||||
docker_secret('MYSQL_ROOT_PASSWORD')
|
||||
docker_secret('PMA_PASSWORD')
|
||||
docker_secret('PMA_HOSTS')
|
||||
docker_secret('PMA_HOST')
|
||||
|
||||
@@ -28,6 +28,7 @@ GREEN="\033[0;32m"
|
||||
RED="\033[0;31m"
|
||||
NC="\033[0m" # No Color
|
||||
|
||||
|
||||
# Find test script
|
||||
if [ -f ./phpmyadmin_test.py ] ; then
|
||||
FILENAME=./phpmyadmin_test.py
|
||||
@@ -75,12 +76,11 @@ fi
|
||||
|
||||
# Perform tests
|
||||
ret=0
|
||||
$FILENAME --url "$PHPMYADMIN_URL" --username root --password $TESTSUITE_PASSWORD $SERVER
|
||||
pytest -q --url "$PHPMYADMIN_URL" --username root --password "$TESTSUITE_PASSWORD" $SERVER $FILENAME
|
||||
ret=$?
|
||||
|
||||
# Show debug output in case of failure
|
||||
if [ $ret -ne 0 ] ; then
|
||||
curl "$PHPMYADMIN_URL"
|
||||
${COMMAND_HOST} ps faux
|
||||
echo "Result of ${PHPMYADMIN_DB_HOSTNAME} tests: ${RED}FAILED${NC}"
|
||||
exit $ret
|
||||
|
||||
Reference in New Issue
Block a user