ngebodh commited on
Commit
26dfd4e
·
1 Parent(s): 52892f3

Fix line endings for shell script

Browse files
Files changed (2) hide show
  1. .gitattributes +1 -0
  2. docker-entrypoint-wrapper.sh +89 -89
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.sh text eol=lf
docker-entrypoint-wrapper.sh CHANGED
@@ -1,90 +1,90 @@
1
- #!/bin/sh
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
- echo "Initializing database..."
14
- initdb -D /data/postgresql/data
15
-
16
- # Modify pg_hba.conf to allow local connections
17
- echo "local all all trust" > /data/postgresql/data/pg_hba.conf
18
- echo "host all all 127.0.0.1/32 trust" >> /data/postgresql/data/pg_hba.conf
19
- echo "host all all ::1/128 trust" >> /data/postgresql/data/pg_hba.conf
20
- echo "host all all 0.0.0.0/0 trust" >> /data/postgresql/data/pg_hba.conf
21
- echo "host all all ::/0 trust" >> /data/postgresql/data/pg_hba.conf
22
- fi
23
-
24
- # Start PostgreSQL with the persistent directories
25
- echo "Starting PostgreSQL..."
26
- pg_ctl -D /data/postgresql/data -o "-c listen_addresses='*' -c unix_socket_directories='/data/postgresql/run'" start
27
-
28
- # Wait for PostgreSQL to be ready (with timeout)
29
- echo "Waiting for PostgreSQL to be ready..."
30
- max_attempts=30
31
- attempt=0
32
- until pg_isready -h localhost -p 5432 2>/dev/null || [ $attempt -ge $max_attempts ]; do
33
- echo "Waiting for PostgreSQL to be ready... ($attempt/$max_attempts)"
34
- sleep 2
35
- attempt=$((attempt + 1))
36
- done
37
-
38
- if [ $attempt -ge $max_attempts ]; then
39
- echo "ERROR: PostgreSQL failed to start after $max_attempts attempts"
40
- exit 1
41
- fi
42
- echo "PostgreSQL is ready!"
43
-
44
- # Create database and roles
45
- echo "Creating database and roles..."
46
- createuser -h /data/postgresql/run -s postgres || true
47
- createdb -h /data/postgresql/run node || true
48
-
49
- # Set NEXTAUTH_URL based on SPACE_HOST if available
50
- if [ -n "$SPACE_ID" ]; then
51
- echo "Setting NEXTAUTH_URL to https://huggingface.co/spaces/${SPACE_ID}"
52
- # export NEXTAUTH_URL="https://huggingface.co/spaces/${SPACE_ID}"
53
- export NEXTAUTH_URL="https://${SPACE_HOST}"
54
- else
55
- echo "WARNING: SPACE_ID not found"
56
- fi
57
-
58
- # Update DATABASE_URL to use TCP connection
59
- export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/node"
60
-
61
- # Export these environment variables to influence Next.js binding
62
- export HOSTNAME="0.0.0.0"
63
- export HOST="0.0.0.0"
64
- export PORT=3000
65
-
66
- # Disable CSP headers to allow for embedded use within HF
67
- export LANGFUSE_CSP_DISABLE="true"
68
-
69
- # Preset oauth env vars based on injected space variables
70
- # See https://huggingface.co/docs/hub/en/spaces-oauth#create-an-oauth-app
71
- export AUTH_CUSTOM_CLIENT_ID=$OAUTH_CLIENT_ID
72
- export AUTH_CUSTOM_CLIENT_SECRET=$OAUTH_CLIENT_SECRET
73
- export AUTH_CUSTOM_ISSUER=$OPENID_PROVIDER_URL
74
- export AUTH_CUSTOM_SCOPE=$OAUTH_SCOPES
75
- export AUTH_CUSTOM_NAME="Hugging Face"
76
-
77
- # Disable authentication via username/password to enforce authentication via HF
78
- export AUTH_DISABLE_USERNAME_PASSWORD="true"
79
-
80
- # Pass through AUTH_DISABLE_SIGNUP value if set, default to false if not set
81
- if [ -n "$AUTH_DISABLE_SIGNUP" ]; then
82
- export AUTH_DISABLE_SIGNUP="$AUTH_DISABLE_SIGNUP"
83
- else
84
- export AUTH_DISABLE_SIGNUP="false"
85
- fi
86
-
87
- # Start Next.js in the background
88
- echo "Starting Next.js..."
89
- ./web/entrypoint.sh node ./web/server.js \
90
  --keepAliveTimeout 110000
 
1
+ #!/bin/sh
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
+ echo "Initializing database..."
14
+ initdb -D /data/postgresql/data
15
+
16
+ # Modify pg_hba.conf to allow local connections
17
+ echo "local all all trust" > /data/postgresql/data/pg_hba.conf
18
+ echo "host all all 127.0.0.1/32 trust" >> /data/postgresql/data/pg_hba.conf
19
+ echo "host all all ::1/128 trust" >> /data/postgresql/data/pg_hba.conf
20
+ echo "host all all 0.0.0.0/0 trust" >> /data/postgresql/data/pg_hba.conf
21
+ echo "host all all ::/0 trust" >> /data/postgresql/data/pg_hba.conf
22
+ fi
23
+
24
+ # Start PostgreSQL with the persistent directories
25
+ echo "Starting PostgreSQL..."
26
+ pg_ctl -D /data/postgresql/data -o "-c listen_addresses='*' -c unix_socket_directories='/data/postgresql/run'" start
27
+
28
+ # Wait for PostgreSQL to be ready (with timeout)
29
+ echo "Waiting for PostgreSQL to be ready..."
30
+ max_attempts=30
31
+ attempt=0
32
+ until pg_isready -h localhost -p 5432 2>/dev/null || [ $attempt -ge $max_attempts ]; do
33
+ echo "Waiting for PostgreSQL to be ready... ($attempt/$max_attempts)"
34
+ sleep 2
35
+ attempt=$((attempt + 1))
36
+ done
37
+
38
+ if [ $attempt -ge $max_attempts ]; then
39
+ echo "ERROR: PostgreSQL failed to start after $max_attempts attempts"
40
+ exit 1
41
+ fi
42
+ echo "PostgreSQL is ready!"
43
+
44
+ # Create database and roles
45
+ echo "Creating database and roles..."
46
+ createuser -h /data/postgresql/run -s postgres || true
47
+ createdb -h /data/postgresql/run node || true
48
+
49
+ # Set NEXTAUTH_URL based on SPACE_HOST if available
50
+ if [ -n "$SPACE_ID" ]; then
51
+ echo "Setting NEXTAUTH_URL to https://huggingface.co/spaces/${SPACE_ID}"
52
+ # export NEXTAUTH_URL="https://huggingface.co/spaces/${SPACE_ID}"
53
+ export NEXTAUTH_URL="https://${SPACE_HOST}"
54
+ else
55
+ echo "WARNING: SPACE_ID not found"
56
+ fi
57
+
58
+ # Update DATABASE_URL to use TCP connection
59
+ export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/node"
60
+
61
+ # Export these environment variables to influence Next.js binding
62
+ export HOSTNAME="0.0.0.0"
63
+ export HOST="0.0.0.0"
64
+ export PORT=3000
65
+
66
+ # Disable CSP headers to allow for embedded use within HF
67
+ export LANGFUSE_CSP_DISABLE="true"
68
+
69
+ # Preset oauth env vars based on injected space variables
70
+ # See https://huggingface.co/docs/hub/en/spaces-oauth#create-an-oauth-app
71
+ export AUTH_CUSTOM_CLIENT_ID=$OAUTH_CLIENT_ID
72
+ export AUTH_CUSTOM_CLIENT_SECRET=$OAUTH_CLIENT_SECRET
73
+ export AUTH_CUSTOM_ISSUER=$OPENID_PROVIDER_URL
74
+ export AUTH_CUSTOM_SCOPE=$OAUTH_SCOPES
75
+ export AUTH_CUSTOM_NAME="Hugging Face"
76
+
77
+ # Disable authentication via username/password to enforce authentication via HF
78
+ export AUTH_DISABLE_USERNAME_PASSWORD="true"
79
+
80
+ # Pass through AUTH_DISABLE_SIGNUP value if set, default to false if not set
81
+ if [ -n "$AUTH_DISABLE_SIGNUP" ]; then
82
+ export AUTH_DISABLE_SIGNUP="$AUTH_DISABLE_SIGNUP"
83
+ else
84
+ export AUTH_DISABLE_SIGNUP="false"
85
+ fi
86
+
87
+ # Start Next.js in the background
88
+ echo "Starting Next.js..."
89
+ ./web/entrypoint.sh node ./web/server.js \
90
  --keepAliveTimeout 110000