fix: some issues with "small" docker improvements (#12564)

* fix: support previous FORCE_BUILD_BEFORE_START variable too

* fix: attempt to fix permission issues and inform properly on failure

* fix: profile-gate redis and re-add profile-gated postgres to main file

For now it's better to maintain compatibility - current postgres users will run mongodb unnecessarily withuot changes, but at least it'll still work fine
This commit is contained in:
Opliko
2024-05-11 02:05:46 +02:00
committed by GitHub
parent f4f0eb30dc
commit bc807c4629
3 changed files with 31 additions and 3 deletions

View File

@@ -30,6 +30,8 @@ services:
# command: ["redis-server", "--save", "60", "1", "--loglevel", "warning"] # uncomment if you want to use snapshotting instead of AOF
volumes:
- redis-data:/data
profiles:
- redis
volumes:
postgres-data:

View File

@@ -33,6 +33,20 @@ services:
# command: ['redis-server', '--save', '60', '1', '--loglevel', 'warning'] # uncomment if you want to use snapshotting instead of AOF
volumes:
- redis-data:/data
profiles:
- redis
postgres:
image: postgres:16.1-alpine
restart: unless-stopped
environment:
POSTGRES_USER: nodebb
POSTGRES_PASSWORD: nodebb
POSTGRES_DB: nodebb
volumes:
- postgres-data:/var/lib/postgresql/data
profiles:
- postgres
volumes:
mongo-data:
@@ -49,6 +63,13 @@ volumes:
type: none
device: ./.docker/database/redis
postgres-data:
driver: local
driver_opts:
o: bind
type: none
device: ./.docker/database/postgresql/data
nodebb-build:
driver: local
driver_opts:

View File

@@ -7,7 +7,7 @@ set_defaults() {
export CONFIG_DIR="${CONFIG_DIR:-/opt/config}"
export CONFIG="$CONFIG_DIR/config.json"
export NODEBB_INIT_VERB="${NODEBB_INIT_VERB:-install}"
export START_BUILD="${START_BUILD:-false}"
export START_BUILD="${START_BUILD:-${FORCE_BUILD_BEFORE_START:-false}}"
export SETUP="${SETUP:-}"
export PACKAGE_MANAGER="${PACKAGE_MANAGER:-npm}"
export OVERRIDE_UPDATE_LOCK="${OVERRIDE_UPDATE_LOCK:-false}"
@@ -24,8 +24,13 @@ check_directory() {
}
fi
if [ ! -w "$dir" ]; then
echo "Error: No write permission for directory $dir"
exit 1
echo "Warning: No write permission for directory $dir, attempting to fix..."
chown -R $USER:$USER "$dir" || true # attempt to change ownership, do not exit on failure
chmod -R 760 "$dir" || true # attempt to change permissions, do not exit on failure
if [ ! -w "$dir" ]; then
echo "Error: No write permission for directory $dir. Exiting..."
exit 1
fi
fi
}