andrewrreed HF Staff commited on
Commit
d0b21bc
·
1 Parent(s): 4160d36

create postgress directories at build time

Browse files
Files changed (1) hide show
  1. Dockerfile +5 -6
Dockerfile CHANGED
@@ -7,10 +7,11 @@ RUN apk update && apk add --no-cache \
7
  postgresql \
8
  postgresql-contrib
9
 
10
- # Create postgres user and data directory
11
- RUN mkdir -p /var/lib/postgresql/data && \
12
- chown -R postgres:postgres /var/lib/postgresql/data && \
13
- chmod 0700 /var/lib/postgresql/data
 
14
 
15
  # Set up environment variables
16
  ENV DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
@@ -23,8 +24,6 @@ ENV NEXTAUTH_URL=http://localhost:3000
23
  COPY <<EOF /docker-entrypoint-wrapper.sh
24
  #!/bin/sh
25
  # Initialize PostgreSQL
26
- mkdir -p /run/postgresql
27
- chown postgres:postgres /run/postgresql
28
  su postgres -c "initdb -D /var/lib/postgresql/data"
29
  su postgres -c "pg_ctl -D /var/lib/postgresql/data -l /var/log/postgresql/postgresql.log -o '-c listen_addresses=*' start"
30
  su postgres -c "createdb -U postgres postgres" || true
 
7
  postgresql \
8
  postgresql-contrib
9
 
10
+ # Create postgres user and data directory with proper permissions
11
+ RUN mkdir -p /var/lib/postgresql/data /run/postgresql && \
12
+ chown -R postgres:postgres /var/lib/postgresql/data /run/postgresql && \
13
+ chmod 0700 /var/lib/postgresql/data && \
14
+ chmod 0755 /run/postgresql
15
 
16
  # Set up environment variables
17
  ENV DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
 
24
  COPY <<EOF /docker-entrypoint-wrapper.sh
25
  #!/bin/sh
26
  # Initialize PostgreSQL
 
 
27
  su postgres -c "initdb -D /var/lib/postgresql/data"
28
  su postgres -c "pg_ctl -D /var/lib/postgresql/data -l /var/log/postgresql/postgresql.log -o '-c listen_addresses=*' start"
29
  su postgres -c "createdb -U postgres postgres" || true