FROM ubuntu:20.04 # Install dependencies RUN apt-get update && apt-get install -y \ build-essential \ libreadline-dev \ zlib1g-dev \ libssl-dev \ libpq-dev \ git \ wget \ ca-certificates # Download and extract PostgreSQL source code RUN wget https://ftp.postgresql.org/pub/source/v14.1/postgresql-14.1.tar.gz RUN tar -xzf postgresql-14.1.tar.gz # Configure and build PostgreSQL WORKDIR /postgresql-14.1 RUN ./configure RUN make RUN make install # Set environment variables ENV POSTGRES_DB=mydb ENV POSTGRES_USER=myuser ENV POSTGRES_PASSWORD=mypassword # Expose the PostgreSQL port EXPOSE 5432 # Start the PostgreSQL server CMD ["postgres", "-D", "/usr/local/pgsql/data"]