Merge pull request 'added support for postgres' (#1) from samuel-p/pixelfed:master into master
Reviewed-on: https://git.zknt.org/dockers/pixelfed/pulls/1master
commit
9093af18da
|
@ -27,7 +27,7 @@ COPY --from=builder /var/www /var/www
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
COPY worker-entrypoint.sh /worker-entrypoint.sh
|
COPY worker-entrypoint.sh /worker-entrypoint.sh
|
||||||
COPY wait-for-db.php /wait-for-db.php
|
COPY wait-for-db.php /wait-for-db.php
|
||||||
RUN apt-install php${PHPVER}-curl php${PHPVER}-zip php${PHPVER}-bcmath php${PHPVER}-intl php${PHPVER}-mbstring php${PHPVER}-xml optipng pngquant jpegoptim gifsicle ffmpeg php${PHPVER}-imagick php${PHPVER}-gd php${PHPVER}-redis php${PHPVER}-mysql &&\
|
RUN apt-install php${PHPVER}-curl php${PHPVER}-zip php${PHPVER}-bcmath php${PHPVER}-intl php${PHPVER}-mbstring php${PHPVER}-xml optipng pngquant jpegoptim gifsicle ffmpeg php${PHPVER}-imagick php${PHPVER}-gd php${PHPVER}-redis php${PHPVER}-mysql php${PHPVER}-pgsql &&\
|
||||||
a2enmod rewrite &&\
|
a2enmod rewrite &&\
|
||||||
sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf &&\
|
sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf &&\
|
||||||
sed -i 's/^post_max_size.*/post_max_size = 100M/g' /etc/php/${PHPVER}/apache2/php.ini &&\
|
sed -i 's/^post_max_size.*/post_max_size = 100M/g' /etc/php/${PHPVER}/apache2/php.ini &&\
|
||||||
|
|
|
@ -1,25 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$conn = mysqli_connect(
|
function connect()
|
||||||
getenv('DB_HOST'),
|
{
|
||||||
getenv('DB_USERNAME'),
|
$connection = getenv('DB_CONNECTION');
|
||||||
getenv('DB_PASSWORD'),
|
$host = getenv('DB_HOST');
|
||||||
getenv('DB_DATABASE'),
|
$username = getenv('DB_USERNAME');
|
||||||
getenv('DB_PORT')
|
$password = getenv('DB_PASSWORD');
|
||||||
);
|
$database = getenv('DB_DATABASE');
|
||||||
|
$port = getenv('DB_PORT');
|
||||||
|
if ($connection === 'mysql') {
|
||||||
|
return mysqli_connect($host, $username, $password, $database, $port);
|
||||||
|
}
|
||||||
|
if ($connection === 'pgsql') {
|
||||||
|
return pg_connect('host=' . $host . ' port=' . $port . ' dbname=' . $database . ' user=' . $username . ' password=' . $password);
|
||||||
|
}
|
||||||
|
throw new Exception('unsupported connection type ' . $connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = connect();
|
||||||
|
|
||||||
$counter = 10;
|
$counter = 10;
|
||||||
$count = 1;
|
$count = 1;
|
||||||
while (!$conn) {
|
while (!$conn) {
|
||||||
echo("Waiting for Database... $count / $counter\n");
|
echo("Waiting for Database... $count / $counter\n");
|
||||||
sleep(2);
|
sleep(2);
|
||||||
$conn = mysqli_connect(
|
$conn = connect();
|
||||||
getenv('DB_HOST'),
|
|
||||||
getenv('DB_USERNAME'),
|
|
||||||
getenv('DB_PASSWORD'),
|
|
||||||
getenv('DB_DATABASE'),
|
|
||||||
getenv('DB_PORT')
|
|
||||||
);
|
|
||||||
$count++;
|
$count++;
|
||||||
if ($count == $counter) {
|
if ($count == $counter) {
|
||||||
echo("Database did not respond after $counter tries, giving up\n");
|
echo("Database did not respond after $counter tries, giving up\n");
|
||||||
|
|
Loading…
Reference in New Issue