File size: 1,456 Bytes
39cc6c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM langfuse/langfuse:2

USER root

# Install PostgreSQL and necessary dependencies
RUN apk update && apk add --no-cache \
    postgresql \
    postgresql-contrib

# Create postgres user and data directory
RUN mkdir -p /var/lib/postgresql/data && \
    chown -R postgres:postgres /var/lib/postgresql/data && \
    chmod 0700 /var/lib/postgresql/data

# Set up environment variables
ENV DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
ENV NEXTAUTH_SECRET=mysecret
ENV SALT=mysalt
ENV ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000
ENV NEXTAUTH_URL=http://localhost:3000

# Create a wrapper script that will start Postgres before running the original entrypoint
COPY <<EOF /docker-entrypoint-wrapper.sh
#!/bin/sh
# Initialize PostgreSQL
mkdir -p /run/postgresql
chown postgres:postgres /run/postgresql
su postgres -c "initdb -D /var/lib/postgresql/data"
su postgres -c "pg_ctl -D /var/lib/postgresql/data -l /var/log/postgresql/postgresql.log -o '-c listen_addresses=*' start"
su postgres -c "createdb -U postgres postgres" || true

# Wait for PostgreSQL to be ready
while ! su postgres -c "pg_isready"; do
  echo "Waiting for PostgreSQL to be ready..."
  sleep 1
done

# Run the original entrypoint script
./web/entrypoint.sh node ./web/server.js --keepAliveTimeout 110000
EOF

RUN chmod +x /docker-entrypoint-wrapper.sh

EXPOSE 3000 5432

ENTRYPOINT ["dumb-init", "--", "/docker-entrypoint-wrapper.sh"]