File size: 734 Bytes
9647270
 
 
 
 
 
 
 
d86b156
 
 
 
 
 
 
9647270
 
 
 
 
d86b156
 
 
9647270
 
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
# Use the official PostgreSQL image as the base image
FROM postgres:13

# Set the environment variables for the PostgreSQL database
ENV POSTGRES_DB=mydb
ENV POSTGRES_USER=myuser
ENV POSTGRES_PASSWORD=mypassword

# Create a custom user and group for PostgreSQL
RUN groupadd -r postgres && useradd -r -g postgres postgres

# Set the ownership of the data directory
RUN mkdir -p /var/lib/postgresql/data && chown -R postgres:postgres /var/lib/postgresql/data

# Copy the init.sql file to the container
COPY init.sql /docker-entrypoint-initdb.d/

# Expose the default PostgreSQL port
EXPOSE 5432

# Run the PostgreSQL process as the custom user
USER postgres

# Start the PostgreSQL server when the container is launched
CMD ["postgres"]