andrewrreed HF staff commited on
Commit
94f1533
·
1 Parent(s): a603a7e

run as user 1000

Browse files
Files changed (1) hide show
  1. docker-entrypoint-wrapper.sh +14 -13
docker-entrypoint-wrapper.sh CHANGED
@@ -2,33 +2,34 @@
2
 
3
  # Create necessary directories in the persistent /data volume
4
  echo "Creating necessary directories in the persistent /data volume..."
5
- su postgres -c "mkdir -p /data/postgresql/data /data/postgresql/run"
6
- su postgres -c "chmod 0700 /data/postgresql/data"
7
- su postgres -c "chmod 0755 /data/postgresql/run"
8
 
9
  # Initialize PostgreSQL if not already initialized
10
  echo "Initializing PostgreSQL if not already initialized..."
11
  if [ ! -f "/data/postgresql/data/PG_VERSION" ]; then
12
- # Initialize as postgres user
13
- su postgres -c "initdb -D /data/postgresql/data"
14
 
15
  # Modify pg_hba.conf to allow local connections
16
- su postgres -c "echo 'local all all trust' > /data/postgresql/data/pg_hba.conf"
17
- su postgres -c "echo 'host all all 127.0.0.1/32 trust' >> /data/postgresql/data/pg_hba.conf"
18
  fi
19
 
20
  # Start PostgreSQL with the persistent directories
21
  echo "Starting PostgreSQL..."
22
- su postgres -c "pg_ctl -D /data/postgresql/data -o '-c listen_addresses=*' -o '-c unix_socket_directories=/data/postgresql/run' start"
23
 
24
  # Create database and roles
25
  echo "Creating database and roles..."
26
- su postgres -c "createuser -s postgres" || true
27
- su postgres -c "createuser -s node" || true
28
- su postgres -c "createdb -U postgres postgres" || true
29
 
30
  # Wait for PostgreSQL to be ready
31
- until su postgres -c "pg_isready -h /data/postgresql/run"; do
 
32
  echo "Waiting for PostgreSQL to be ready..."
33
  sleep 1
34
  done
@@ -37,4 +38,4 @@ done
37
  export DATABASE_URL="postgresql://postgres:postgres@%2Fdata%2Fpostgresql%2Frun:5432/postgres"
38
 
39
  # Run the original entrypoint script
40
- ./web/entrypoint.sh node ./web/server.js --keepAliveTimeout 110000
 
2
 
3
  # Create necessary directories in the persistent /data volume
4
  echo "Creating necessary directories in the persistent /data volume..."
5
+ mkdir -p /data/postgresql/data /data/postgresql/run
6
+ chmod 0700 /data/postgresql/data
7
+ chmod 0755 /data/postgresql/run
8
 
9
  # Initialize PostgreSQL if not already initialized
10
  echo "Initializing PostgreSQL if not already initialized..."
11
  if [ ! -f "/data/postgresql/data/PG_VERSION" ]; then
12
+ # Initialize database
13
+ initdb -D /data/postgresql/data
14
 
15
  # Modify pg_hba.conf to allow local connections
16
+ echo "local all all trust" > /data/postgresql/data/pg_hba.conf
17
+ echo "host all all 127.0.0.1/32 trust" >> /data/postgresql/data/pg_hba.conf
18
  fi
19
 
20
  # Start PostgreSQL with the persistent directories
21
  echo "Starting PostgreSQL..."
22
+ pg_ctl -D /data/postgresql/data -o "-c listen_addresses='*' -c unix_socket_directories='/data/postgresql/run'" start
23
 
24
  # Create database and roles
25
  echo "Creating database and roles..."
26
+ createuser -s postgres || true
27
+ createuser -s node || true
28
+ createdb postgres || true
29
 
30
  # Wait for PostgreSQL to be ready
31
+ echo "Waiting for PostgreSQL to be ready..."
32
+ until pg_isready -h /data/postgresql/run; do
33
  echo "Waiting for PostgreSQL to be ready..."
34
  sleep 1
35
  done
 
38
  export DATABASE_URL="postgresql://postgres:postgres@%2Fdata%2Fpostgresql%2Frun:5432/postgres"
39
 
40
  # Run the original entrypoint script
41
+ ./web/entrypoint.sh node ./web/server.js --keepAliveTimeout 110000