mirror of
https://github.com/Retropex/dockerfile-deps.git
synced 2025-05-12 00:20:42 +02:00
Add WooCommerce (#53)
Transfered what we had in the docker-woocommerce repository, which is now archived. This contains what has been merged with btcpayserver/docker-woocommerce#7 and sets everything up for a new 3.1.0 release of the image, which now also has an `arm64v8` compatible version. Previously this was `amd64` only.
This commit is contained in:
parent
e0430e2cef
commit
1f7cf5d993
124
WooCommerce/3.1.0/.dockerignore
Normal file
124
WooCommerce/3.1.0/.dockerignore
Normal file
@ -0,0 +1,124 @@
|
||||
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
|
||||
**/[Bb]in/
|
||||
**/[Oo]bj/
|
||||
node_modules/
|
||||
dist/
|
||||
|
||||
# mstest test results
|
||||
TestResults
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
|
||||
# NuGet Packages Directory
|
||||
packages
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
[Bb]in
|
||||
[Oo]bj
|
||||
sql
|
||||
TestResults
|
||||
[Tt]est[Rr]esult*
|
||||
*.Cache
|
||||
ClientBin
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*.dbmdl
|
||||
Generated_Code #added for RIA/Silverlight projects
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
|
||||
src/Rapporteringsregisteret.Web/assets/less/*.css
|
||||
|
||||
MetricResults/
|
||||
*.sln.ide/
|
||||
|
||||
_configs/
|
||||
|
||||
# vnext stuff
|
||||
bower_components
|
||||
output
|
||||
|
||||
.vs
|
||||
**/launchSettings.json
|
293
WooCommerce/3.1.0/docker-entrypoint.sh
Executable file
293
WooCommerce/3.1.0/docker-entrypoint.sh
Executable file
@ -0,0 +1,293 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
[ -f /etc/apache2/conf-enabled/servername.conf ] && rm /etc/apache2/conf-enabled/servername.conf
|
||||
if [ ! -z $WOOCOMMERCE_HOST ]; then
|
||||
echo "ServerName $WOOCOMMERCE_HOST" >> /etc/apache2/conf-enabled/servername.conf
|
||||
fi
|
||||
|
||||
if [ -n "${WOOCOMMERCE_HIDDENSERVICE_HOSTNAME_FILE:-}" ]; then
|
||||
echo "Waiting $WOOCOMMERCE_HIDDENSERVICE_HOSTNAME_FILE to be created by tor..."
|
||||
while [ ! -f "$WOOCOMMERCE_HIDDENSERVICE_HOSTNAME_FILE" ]; do sleep 1; done
|
||||
HIDDENSERVICE_ONION="$(head -n 1 "$WOOCOMMERCE_HIDDENSERVICE_HOSTNAME_FILE")"
|
||||
echo "ServerName $HIDDENSERVICE_ONION" >> /etc/apache2/conf-enabled/servername.conf
|
||||
fi
|
||||
|
||||
# usage: file_env VAR [DEFAULT]
|
||||
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
|
||||
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
|
||||
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
|
||||
file_env() {
|
||||
local var="$1"
|
||||
local fileVar="${var}_FILE"
|
||||
local def="${2:-}"
|
||||
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
||||
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
|
||||
exit 1
|
||||
fi
|
||||
local val="$def"
|
||||
if [ "${!var:-}" ]; then
|
||||
val="${!var}"
|
||||
elif [ "${!fileVar:-}" ]; then
|
||||
val="$(< "${!fileVar}")"
|
||||
fi
|
||||
export "$var"="$val"
|
||||
unset "$fileVar"
|
||||
}
|
||||
|
||||
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
||||
if [ "$(id -u)" = '0' ]; then
|
||||
case "$1" in
|
||||
apache2*)
|
||||
user="${APACHE_RUN_USER:-www-data}"
|
||||
group="${APACHE_RUN_GROUP:-www-data}"
|
||||
|
||||
# strip off any '#' symbol ('#1000' is valid syntax for Apache)
|
||||
pound='#'
|
||||
user="${user#$pound}"
|
||||
group="${group#$pound}"
|
||||
;;
|
||||
*) # php-fpm
|
||||
user='www-data'
|
||||
group='www-data'
|
||||
;;
|
||||
esac
|
||||
else
|
||||
user="$(id -u)"
|
||||
group="$(id -g)"
|
||||
fi
|
||||
|
||||
if [ ! -e index.php ] && [ ! -e wp-includes/version.php ]; then
|
||||
echo >&2 "WordPress not found in $PWD - copying now..."
|
||||
if [ -n "$(ls -A)" ]; then
|
||||
echo >&2 "WARNING: $PWD is not empty! (copying anyhow)"
|
||||
fi
|
||||
sourceTarArgs=(
|
||||
--create
|
||||
--file -
|
||||
--directory /usr/src/wordpress
|
||||
--owner "$user" --group "$group"
|
||||
)
|
||||
targetTarArgs=(
|
||||
--extract
|
||||
--file -
|
||||
)
|
||||
if [ "$user" != '0' ]; then
|
||||
# avoid "tar: .: Cannot utime: Operation not permitted" and "tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted"
|
||||
targetTarArgs+=( --no-overwrite-dir )
|
||||
fi
|
||||
tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"
|
||||
echo >&2 "Complete! WordPress has been successfully copied to $PWD"
|
||||
if [ ! -e .htaccess ]; then
|
||||
# NOTE: The "Indexes" option is disabled in the php:apache base image
|
||||
cat > .htaccess <<-'EOF'
|
||||
# BEGIN WordPress
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteRule ^index\.php$ - [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . /index.php [L]
|
||||
</IfModule>
|
||||
# END WordPress
|
||||
EOF
|
||||
chown "$user:$group" .htaccess
|
||||
fi
|
||||
fi
|
||||
|
||||
# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version
|
||||
|
||||
# allow any of these "Authentication Unique Keys and Salts." to be specified via
|
||||
# environment variables with a "WORDPRESS_" prefix (ie, "WORDPRESS_AUTH_KEY")
|
||||
uniqueEnvs=(
|
||||
AUTH_KEY
|
||||
SECURE_AUTH_KEY
|
||||
LOGGED_IN_KEY
|
||||
NONCE_KEY
|
||||
AUTH_SALT
|
||||
SECURE_AUTH_SALT
|
||||
LOGGED_IN_SALT
|
||||
NONCE_SALT
|
||||
)
|
||||
envs=(
|
||||
WORDPRESS_DB_HOST
|
||||
WORDPRESS_DB_USER
|
||||
WORDPRESS_DB_PASSWORD
|
||||
WORDPRESS_DB_NAME
|
||||
WORDPRESS_DB_CHARSET
|
||||
WORDPRESS_DB_COLLATE
|
||||
"${uniqueEnvs[@]/#/WORDPRESS_}"
|
||||
WORDPRESS_TABLE_PREFIX
|
||||
WORDPRESS_DEBUG
|
||||
WORDPRESS_CONFIG_EXTRA
|
||||
)
|
||||
haveConfig=
|
||||
for e in "${envs[@]}"; do
|
||||
file_env "$e"
|
||||
if [ -z "$haveConfig" ] && [ -n "${!e}" ]; then
|
||||
haveConfig=1
|
||||
fi
|
||||
done
|
||||
|
||||
# linking backwards-compatibility
|
||||
if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
|
||||
haveConfig=1
|
||||
# host defaults to "mysql" below if unspecified
|
||||
: "${WORDPRESS_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
|
||||
if [ "$WORDPRESS_DB_USER" = 'root' ]; then
|
||||
: "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD:-}}"
|
||||
else
|
||||
: "${WORDPRESS_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD:-}}"
|
||||
fi
|
||||
: "${WORDPRESS_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-}}"
|
||||
fi
|
||||
|
||||
# only touch "wp-config.php" if we have environment-supplied configuration values
|
||||
if [ "$haveConfig" ]; then
|
||||
: "${WORDPRESS_DB_HOST:=mysql}"
|
||||
: "${WORDPRESS_DB_USER:=root}"
|
||||
: "${WORDPRESS_DB_PASSWORD:=}"
|
||||
: "${WORDPRESS_DB_NAME:=wordpress}"
|
||||
: "${WORDPRESS_DB_CHARSET:=utf8}"
|
||||
: "${WORDPRESS_DB_COLLATE:=}"
|
||||
|
||||
# version 4.4.1 decided to switch to windows line endings, that breaks our seds and awks
|
||||
# https://github.com/docker-library/wordpress/issues/116
|
||||
# https://github.com/WordPress/WordPress/commit/1acedc542fba2482bab88ec70d4bea4b997a92e4
|
||||
sed -ri -e 's/\r$//' wp-config*
|
||||
|
||||
if [ ! -e wp-config.php ]; then
|
||||
awk '
|
||||
/^\/\*.*stop editing.*\*\/$/ && c == 0 {
|
||||
c = 1
|
||||
system("cat")
|
||||
if (ENVIRON["WORDPRESS_CONFIG_EXTRA"]) {
|
||||
print "// WORDPRESS_CONFIG_EXTRA"
|
||||
print ENVIRON["WORDPRESS_CONFIG_EXTRA"] "\n"
|
||||
}
|
||||
}
|
||||
{ print }
|
||||
' wp-config-sample.php > wp-config.php <<'EOPHP'
|
||||
// If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact
|
||||
// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
}
|
||||
|
||||
EOPHP
|
||||
chown "$user:$group" wp-config.php
|
||||
elif [ -e wp-config.php ] && [ -n "$WORDPRESS_CONFIG_EXTRA" ] && [[ "$(< wp-config.php)" != *"$WORDPRESS_CONFIG_EXTRA"* ]]; then
|
||||
# (if the config file already contains the requested PHP code, don't print a warning)
|
||||
echo >&2
|
||||
echo >&2 'WARNING: environment variable "WORDPRESS_CONFIG_EXTRA" is set, but "wp-config.php" already exists'
|
||||
echo >&2 ' The contents of this variable will _not_ be inserted into the existing "wp-config.php" file.'
|
||||
echo >&2 ' (see https://github.com/docker-library/wordpress/issues/333 for more details)'
|
||||
echo >&2
|
||||
fi
|
||||
|
||||
# see http://stackoverflow.com/a/2705678/433558
|
||||
sed_escape_lhs() {
|
||||
echo "$@" | sed -e 's/[]\/$*.^|[]/\\&/g'
|
||||
}
|
||||
sed_escape_rhs() {
|
||||
echo "$@" | sed -e 's/[\/&]/\\&/g'
|
||||
}
|
||||
php_escape() {
|
||||
local escaped="$(php -r 'var_export(('"$2"') $argv[1]);' -- "$1")"
|
||||
if [ "$2" = 'string' ] && [ "${escaped:0:1}" = "'" ]; then
|
||||
escaped="${escaped//$'\n'/"' + \"\\n\" + '"}"
|
||||
fi
|
||||
echo "$escaped"
|
||||
}
|
||||
set_config() {
|
||||
key="$1"
|
||||
value="$2"
|
||||
var_type="${3:-string}"
|
||||
start="(['\"])$(sed_escape_lhs "$key")\2\s*,"
|
||||
end="\);"
|
||||
if [ "${key:0:1}" = '$' ]; then
|
||||
start="^(\s*)$(sed_escape_lhs "$key")\s*="
|
||||
end=";"
|
||||
fi
|
||||
sed -ri -e "s/($start\s*).*($end)$/\1$(sed_escape_rhs "$(php_escape "$value" "$var_type")")\3/" wp-config.php
|
||||
}
|
||||
|
||||
set_config 'DB_HOST' "$WORDPRESS_DB_HOST"
|
||||
set_config 'DB_USER' "$WORDPRESS_DB_USER"
|
||||
set_config 'DB_PASSWORD' "$WORDPRESS_DB_PASSWORD"
|
||||
set_config 'DB_NAME' "$WORDPRESS_DB_NAME"
|
||||
set_config 'DB_CHARSET' "$WORDPRESS_DB_CHARSET"
|
||||
set_config 'DB_COLLATE' "$WORDPRESS_DB_COLLATE"
|
||||
|
||||
for unique in "${uniqueEnvs[@]}"; do
|
||||
uniqVar="WORDPRESS_$unique"
|
||||
if [ -n "${!uniqVar}" ]; then
|
||||
set_config "$unique" "${!uniqVar}"
|
||||
else
|
||||
# if not specified, let's generate a random value
|
||||
currentVal="$(sed -rn -e "s/define\((([\'\"])$unique\2\s*,\s*)(['\"])(.*)\3\);/\4/p" wp-config.php)"
|
||||
if [ "$currentVal" = 'put your unique phrase here' ]; then
|
||||
set_config "$unique" "$(head -c1m /dev/urandom | sha1sum | cut -d' ' -f1)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$WORDPRESS_TABLE_PREFIX" ]; then
|
||||
set_config '$table_prefix' "$WORDPRESS_TABLE_PREFIX"
|
||||
fi
|
||||
|
||||
if [ "$WORDPRESS_DEBUG" ]; then
|
||||
set_config 'WP_DEBUG' 1 boolean
|
||||
fi
|
||||
|
||||
TERM=dumb php -- <<'EOPHP'
|
||||
<?php
|
||||
// database might not exist, so let's try creating it (just to be safe)
|
||||
|
||||
$stderr = fopen('php://stderr', 'w');
|
||||
|
||||
// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Alternate_Port
|
||||
// "hostname:port"
|
||||
// https://codex.wordpress.org/Editing_wp-config.php#MySQL_Sockets_or_Pipes
|
||||
// "hostname:unix-socket-path"
|
||||
list($host, $socket) = explode(':', getenv('WORDPRESS_DB_HOST'), 2);
|
||||
$port = 0;
|
||||
if (is_numeric($socket)) {
|
||||
$port = (int) $socket;
|
||||
$socket = null;
|
||||
}
|
||||
$user = getenv('WORDPRESS_DB_USER');
|
||||
$pass = getenv('WORDPRESS_DB_PASSWORD');
|
||||
$dbName = getenv('WORDPRESS_DB_NAME');
|
||||
|
||||
$maxTries = 10;
|
||||
do {
|
||||
$mysql = new mysqli($host, $user, $pass, '', $port, $socket);
|
||||
if ($mysql->connect_error) {
|
||||
fwrite($stderr, "\n" . 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n");
|
||||
--$maxTries;
|
||||
if ($maxTries <= 0) {
|
||||
exit(1);
|
||||
}
|
||||
sleep(3);
|
||||
}
|
||||
} while ($mysql->connect_error);
|
||||
|
||||
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($dbName) . '`')) {
|
||||
fwrite($stderr, "\n" . 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n");
|
||||
$mysql->close();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$mysql->close();
|
||||
EOPHP
|
||||
fi
|
||||
|
||||
# now that we're definitely done writing configuration, let's clear out the relevant envrionment variables (so that stray "phpinfo()" calls don't leak secrets from our code)
|
||||
for e in "${envs[@]}"; do
|
||||
unset "$e"
|
||||
done
|
||||
fi
|
||||
|
||||
exec "$@"
|
32
WooCommerce/3.1.0/linuxamd64.Dockerfile
Normal file
32
WooCommerce/3.1.0/linuxamd64.Dockerfile
Normal file
@ -0,0 +1,32 @@
|
||||
FROM wordpress:6.0.2-php8.0
|
||||
|
||||
ENV WOOCOMMERCE_VERSION 6.9.4
|
||||
ENV BTCPAY_PLUGIN_VERSION 1.1.1
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends unzip wget \
|
||||
&& wget https://downloads.wordpress.org/plugin/woocommerce.$WOOCOMMERCE_VERSION.zip -O /tmp/temp.zip \
|
||||
&& wget https://downloads.wordpress.org/plugin/btcpay-greenfield-for-woocommerce.$BTCPAY_PLUGIN_VERSION.zip -O /tmp/temp2.zip \
|
||||
&& cd /usr/src/wordpress/wp-content/plugins \
|
||||
&& unzip /tmp/temp.zip \
|
||||
&& unzip /tmp/temp2.zip \
|
||||
&& rm /tmp/temp.zip \
|
||||
&& rm /tmp/temp2.zip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install the gmp, mcrypt and soap extensions
|
||||
RUN apt-get update -y
|
||||
RUN apt-get install -y libxml2-dev
|
||||
RUN docker-php-ext-install soap
|
||||
|
||||
# Download WordPress CLI
|
||||
RUN curl -L "https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar" > /usr/bin/wp && chmod +x /usr/bin/wp
|
||||
|
||||
RUN { \
|
||||
echo 'file_uploads = On'; \
|
||||
echo 'post_max_size=100M'; \
|
||||
echo 'upload_max_filesize=100M'; \
|
||||
} > /usr/local/etc/php/conf.d/uploads.ini
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
VOLUME ["/var/www/html"]
|
32
WooCommerce/3.1.0/linuxarm64v8.Dockerfile
Normal file
32
WooCommerce/3.1.0/linuxarm64v8.Dockerfile
Normal file
@ -0,0 +1,32 @@
|
||||
FROM wordpress:6.0.2-php8.0
|
||||
|
||||
ENV WOOCOMMERCE_VERSION 6.9.4
|
||||
ENV BTCPAY_PLUGIN_VERSION 1.1.1
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends unzip wget \
|
||||
&& wget https://downloads.wordpress.org/plugin/woocommerce.$WOOCOMMERCE_VERSION.zip -O /tmp/temp.zip \
|
||||
&& wget https://downloads.wordpress.org/plugin/btcpay-greenfield-for-woocommerce.$BTCPAY_PLUGIN_VERSION.zip -O /tmp/temp2.zip \
|
||||
&& cd /usr/src/wordpress/wp-content/plugins \
|
||||
&& unzip /tmp/temp.zip \
|
||||
&& unzip /tmp/temp2.zip \
|
||||
&& rm /tmp/temp.zip \
|
||||
&& rm /tmp/temp2.zip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install the gmp, mcrypt and soap extensions
|
||||
RUN apt-get update -y
|
||||
RUN apt-get install -y libxml2-dev
|
||||
RUN docker-php-ext-install soap
|
||||
|
||||
# Download WordPress CLI
|
||||
RUN curl -L "https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar" > /usr/bin/wp && chmod +x /usr/bin/wp
|
||||
|
||||
RUN { \
|
||||
echo 'file_uploads = On'; \
|
||||
echo 'post_max_size=100M'; \
|
||||
echo 'upload_max_filesize=100M'; \
|
||||
} > /usr/local/etc/php/conf.d/uploads.ini
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
VOLUME ["/var/www/html"]
|
Loading…
Reference in New Issue
Block a user