bpandey23 commited on
Commit
36faa5c
1 Parent(s): d20b5ef

Create entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +26 -0
entrypoint.sh ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Set the environment variables for the PostgreSQL database
4
+ export POSTGRES_DB=my_database
5
+ export POSTGRES_USER=my_username
6
+ export POSTGRES_PASSWORD=my_password
7
+
8
+ # Create the PostgreSQL database and user
9
+ su - postgres -c "psql -c \"CREATE DATABASE $POSTGRES_DB;\""
10
+ su - postgres -c "psql -c \"CREATE USER $POSTGRES_USER WITH PASSWORD '$POSTGRES_PASSWORD';\""
11
+ su - postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;\""
12
+
13
+ # Create a table and insert sample data
14
+ su - postgres -c "psql -d $POSTGRES_DB -c \"
15
+ CREATE TABLE users (
16
+ id SERIAL PRIMARY KEY,
17
+ name VARCHAR(50) NOT NULL,
18
+ email VARCHAR(50) UNIQUE NOT NULL
19
+ );
20
+ INSERT INTO users (name, email) VALUES
21
+ ('John Doe', '[email protected]'),
22
+ ('Jane Smith', '[email protected]');
23
+ \""
24
+
25
+ # Start the PostgreSQL service
26
+ exec postgres