Compare commits

..

4 Commits

Author SHA1 Message Date
f77b409a45 Merge 7784559b85 into 0e58189b97 2025-01-27 02:32:57 +00:00
7784559b85 Run migrations when installing
This throws errors, but they can be ignored.
2023-12-30 17:40:40 -08:00
4d52431c95 Check if tables exist before installing
This works better than checking just the database, because it could be
that an empty database has already been created (with e.g. Docker
Compose).

TABLES_EXIST should be empty if no tables, or will return a 1
for *each* table that exists.
2023-12-30 17:39:24 -08:00
64d2a60888 Move user create outside of database-exists check 2023-12-25 10:24:57 -08:00
4 changed files with 20 additions and 11 deletions

View File

@ -13,7 +13,7 @@ FROM alpine:3.18
COPY --from=builder /go/bin/envsubst /usr/bin/envsubst
ARG WALLABAG_VERSION=2.6.13
ARG WALLABAG_VERSION=2.6.10
RUN set -ex \
&& apk add --no-cache \
@ -32,7 +32,6 @@ RUN set -ex \
php81-iconv \
php81-json \
php81-mbstring \
php81-opcache \
php81-openssl \
php81-pecl-amqp \
php81-pecl-imagick \
@ -84,8 +83,6 @@ ENV PATH="${PATH}:/var/www/wallabag/bin"
# Set console entry path
WORKDIR /var/www/wallabag
HEALTHCHECK CMD curl --fail --silent --show-error --user-agent healthcheck http://localhost/api/info || exit 1
EXPOSE 80
ENTRYPOINT ["/entrypoint.sh"]
CMD ["wallabag"]

View File

@ -131,6 +131,10 @@ services:
- "80"
volumes:
- /opt/wallabag/images:/var/www/wallabag/web/assets/images
healthcheck:
test: ["CMD", "wget" ,"--no-verbose", "--tries=1", "--spider", "http://localhost/api/info"]
interval: 1m
timeout: 3s
depends_on:
- db
- redis

View File

@ -74,18 +74,25 @@ provisioner() {
# Configure Postgres database
if [ "$SYMFONY__ENV__DATABASE_DRIVER" = "pdo_pgsql" ] && [ "$POPULATE_DATABASE" = "True" ] && [ "$POSTGRES_PASSWORD" != "" ] ; then
export PGPASSWORD="${POSTGRES_PASSWORD}"
USER_EXISTS="$(psql -qAt -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
-c "SELECT 1 FROM pg_roles WHERE rolname = '${SYMFONY__ENV__DATABASE_USER}';")"
if [ "$USER_EXISTS" != "1" ]; then
psql -q -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
-c "CREATE ROLE ${SYMFONY__ENV__DATABASE_USER} with PASSWORD '${SYMFONY__ENV__DATABASE_PASSWORD}' LOGIN;"
fi
DATABASE_EXISTS="$(psql -qAt -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
-c "SELECT 1 FROM pg_catalog.pg_database WHERE datname = '${SYMFONY__ENV__DATABASE_NAME}';")"
if [ "$DATABASE_EXISTS" != "1" ]; then
echo "Configuring the Postgres database ..."
psql -q -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
-c "CREATE DATABASE ${SYMFONY__ENV__DATABASE_NAME};"
USER_EXISTS="$(psql -qAt -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
-c "SELECT 1 FROM pg_roles WHERE rolname = '${SYMFONY__ENV__DATABASE_USER}';")"
if [ "$USER_EXISTS" != "1" ]; then
psql -q -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
-c "CREATE ROLE ${SYMFONY__ENV__DATABASE_USER} with PASSWORD '${SYMFONY__ENV__DATABASE_PASSWORD}' LOGIN;"
fi
fi
TABLES_EXIST="$(psql -qAt -h "${SYMFONY__ENV__DATABASE_HOST}" -p "${SYMFONY__ENV__DATABASE_PORT}" -U "${POSTGRES_USER}" \
-c "SELECT 1 FROM pg_catalog.pg_tables WHERE schemaname = 'public';")"
if [ "$TABLES_EXIST" == "" ]; then
echo "Installing Wallabag ..."
exec su -c "bin/console doctrine:migrations:migrate --env=prod --no-interaction" -s /bin/sh nobody
install_wallabag
else
echo "WARN: Postgres database is already configured. Remove the environment variable with root password."

View File

@ -35,7 +35,8 @@ http {
}
server {
listen [::]:80 ipv6only=off;
listen 80;
listen [::0]:80;
server_name _;
root /var/www/wallabag/web;