Skip to content

Commit

Permalink
fix: some issues with "small" docker improvements (#12564)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
oplik0 committed May 11, 2024
1 parent f4f0eb3 commit bc807c4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docker-compose-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
11 changes: 8 additions & 3 deletions install/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
}

Expand Down

0 comments on commit bc807c4

Please sign in to comment.