Skip to content

Commit

Permalink
data-serving-relational: use gosu instead of sudo for tty-less operation
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-zero committed Nov 29, 2023
1 parent 07ec9a2 commit a67b88d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion benchmarks/data-serving-relational/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
FROM cloudsuite/postgresql:15

# Install sudo for user switching
RUN apt update && apt install sudo python3 -y
RUN set -eux ; \
apt update ; \
apt install sudo python3 gosu -y ; \
rm -rf /var/lib/apt/lists/* ; \
gosu postgres true

# Make the database access public
RUN echo 'host\tall\tcloudsuite\t0.0.0.0/0\tscram-sha-256' >> /etc/postgresql/15/main/pg_hba.conf
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/data-serving-relational/server/docker-entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def save_dict(config_dict, lines):
f.writelines(file_txt)

os.system("service postgresql start")
os.system("sudo -u postgres psql -c \"CREATE USER cloudsuite WITH PASSWORD 'cloudsuite';\"") # Create the user called `cloudsuite`
os.system("sudo -u postgres psql -c \"CREATE DATABASE sbtest;\"") # Create a table named sbtest
os.system("sudo -u postgres psql -c \"GRANT ALL PRIVILEGES ON DATABASE sbtest TO cloudsuite\"") # Gave permission to this table
os.system("sudo -u postgres psql sbtest -c \"GRANT ALL ON SCHEMA public TO cloudsuite;\"")
os.system("sudo -u postgres psql")
os.system("gosu postgres psql -c \"CREATE USER cloudsuite WITH PASSWORD 'cloudsuite';\"") # Create the user called `cloudsuite`
os.system("gosu postgres psql -c \"CREATE DATABASE sbtest;\"") # Create a table named sbtest
os.system("gosu postgres psql -c \"GRANT ALL PRIVILEGES ON DATABASE sbtest TO cloudsuite\"") # Gave permission to this table
os.system("gosu postgres psql sbtest -c \"GRANT ALL ON SCHEMA public TO cloudsuite;\"")
os.system("gosu postgres psql")

0 comments on commit a67b88d

Please sign in to comment.