Start portal mariadb db docker with non root user 59/111059/1
authorSandeep Shah <sandeeplinux1068@gmail.com>
Fri, 7 Aug 2020 21:45:44 +0000 (16:45 -0500)
committerSandeep Shah <sandeeplinux1068@gmail.com>
Fri, 7 Aug 2020 21:45:44 +0000 (16:45 -0500)
Modification to Dockerfile to start maria-db docker as
a non root user. Leveraged user 'mysql' already created
by the mariaDB image

Issue-ID: PORTAL-966
Signed-off-by: SandeepLinux <Sandeep.Shah@att.com>
Change-Id: I79c9bc00778a562b5b53265933ee8c19e45d9055

deliveries/Dockerfile.mariadb

index e9c5e9f..8dffd0e 100644 (file)
@@ -6,6 +6,13 @@ ARG DB_SCRIPT_DIR=${DB_SCRIPT_DIR}
 #Add config file
 COPY my.cnf /etc/mysql/my.cnf
 
+# mysql user and group already created by mariadb image
+
+ARG user=mysql
+ARG group=mysql
+
+RUN mkdir /opt/$user && chown -R $user:$group /opt/$user
+
 # Scripts are executed in alphabetical order
 
 # Portal DDL and DML at v3.2
@@ -20,3 +27,8 @@ COPY ${DB_SCRIPT_DIR}/EcompSdkDDLMySql_3_2_Common.sql       /docker-entrypoint-i
 COPY ${DB_SCRIPT_DIR}/EcompSdkDDLMySql_3_2_OS.sql           /docker-entrypoint-initdb.d/
 COPY ${DB_SCRIPT_DIR}/EcompSdkDMLMySql_3_2_Common.sql       /docker-entrypoint-initdb.d/
 COPY ${DB_SCRIPT_DIR}/EcompSdkDMLMySql_3_2_OS.sql           /docker-entrypoint-initdb.d/
+
+RUN chown $user:$group /opt /var -R
+RUN chmod 777 /var/lib/mysql
+
+USER mysql