bpandey23 commited on
Commit
6b37c94
·
verified ·
1 Parent(s): d86b156

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +3 -2
Dockerfile CHANGED
@@ -6,8 +6,9 @@ ENV POSTGRES_DB=mydb
6
  ENV POSTGRES_USER=myuser
7
  ENV POSTGRES_PASSWORD=mypassword
8
 
9
- # Create a custom user and group for PostgreSQL
10
- RUN groupadd -r postgres && useradd -r -g postgres postgres
 
11
 
12
  # Set the ownership of the data directory
13
  RUN mkdir -p /var/lib/postgresql/data && chown -R postgres:postgres /var/lib/postgresql/data
 
6
  ENV POSTGRES_USER=myuser
7
  ENV POSTGRES_PASSWORD=mypassword
8
 
9
+ # Check if the postgres user and group exist, and create them if not
10
+ RUN if ! id -g postgres > /dev/null 2>&1; then groupadd -r postgres; fi
11
+ RUN if ! id -u postgres > /dev/null 2>&1; then useradd -r -g postgres postgres; fi
12
 
13
  # Set the ownership of the data directory
14
  RUN mkdir -p /var/lib/postgresql/data && chown -R postgres:postgres /var/lib/postgresql/data