Commit
·
94f1533
1
Parent(s):
a603a7e
run as user 1000
Browse files- 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 |
-
|
6 |
-
|
7 |
-
|
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
|
13 |
-
|
14 |
|
15 |
# Modify pg_hba.conf to allow local connections
|
16 |
-
|
17 |
-
|
18 |
fi
|
19 |
|
20 |
# Start PostgreSQL with the persistent directories
|
21 |
echo "Starting PostgreSQL..."
|
22 |
-
|
23 |
|
24 |
# Create database and roles
|
25 |
echo "Creating database and roles..."
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
# Wait for PostgreSQL to be ready
|
31 |
-
|
|
|
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
|