mirror of https://github.com/docker/docs.git
[PATHC 3/4] Only create the needed tables
Make database notaryserver and notarysigner only create the tables they need. The signer only needs the private_keys table, and the server only needs the timestamp_keys and tuf_files tables. Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
parent
9427c372af
commit
91d66f5e7a
|
@ -7,8 +7,9 @@ RUN apt-get update \
|
|||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ADD start /start
|
||||
ADD initial.sql /initial.sql
|
||||
ADD migrate.sql /migrate.sql
|
||||
ADD initial-notaryserver.sql /initial-notaryserver.sql
|
||||
ADD initial-notarysigner.sql /initial-notarysigner.sql
|
||||
ADD migrate-notaryserver.sql /migrate-notaryserver.sql
|
||||
RUN chmod 755 /start
|
||||
|
||||
EXPOSE 3306
|
||||
|
|
|
@ -18,21 +18,3 @@ CREATE TABLE `timestamp_keys` (
|
|||
`public` blob NOT NULL,
|
||||
PRIMARY KEY (`gun`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `private_keys`;
|
||||
CREATE TABLE `private_keys` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`deleted_at` timestamp NULL DEFAULT NULL,
|
||||
`key_id` varchar(255) NOT NULL,
|
||||
`encryption_alg` varchar(255) NOT NULL,
|
||||
`keywrap_alg` varchar(255) NOT NULL,
|
||||
`algorithm` varchar(50) NOT NULL,
|
||||
`passphrase_alias` varchar(50) NOT NULL,
|
||||
`public` blob NOT NULL,
|
||||
`private` blob NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`key_id`),
|
||||
UNIQUE (`key_id`,`algorithm`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
@ -0,0 +1,17 @@
|
|||
DROP TABLE IF EXISTS `private_keys`;
|
||||
CREATE TABLE `private_keys` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL,
|
||||
`deleted_at` timestamp NULL DEFAULT NULL,
|
||||
`key_id` varchar(255) NOT NULL,
|
||||
`encryption_alg` varchar(255) NOT NULL,
|
||||
`keywrap_alg` varchar(255) NOT NULL,
|
||||
`algorithm` varchar(50) NOT NULL,
|
||||
`passphrase_alias` varchar(50) NOT NULL,
|
||||
`public` blob NOT NULL,
|
||||
`private` blob NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`key_id`),
|
||||
UNIQUE (`key_id`,`algorithm`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
@ -1,4 +1,4 @@
|
|||
-- This migrates initial.sql to tables that are needed for GORM
|
||||
-- This migrates initial-notaryserver.sql to tables that are needed for GORM
|
||||
|
||||
ALTER TABLE `tuf_files`
|
||||
ADD COLUMN `created_at` timestamp NULL DEFAULT NULL AFTER `id`,
|
|
@ -141,15 +141,17 @@ if [ -n "${DB_USER}" -o -n "${DB_NAME}" ]; then
|
|||
echo "Granting access to database \"$db\" for user \"${DB_USER_SERVER}\"..."
|
||||
mysql --defaults-file=/etc/mysql/debian.cnf \
|
||||
-e "GRANT ALL PRIVILEGES ON \`$db\`.* TO '${DB_USER_SERVER}' IDENTIFIED BY '${DB_PASS_SERVER}';"
|
||||
# Create our Database:
|
||||
mysql -uroot $db < ./initial-notaryserver.sql
|
||||
mysql -uroot $db < ./migrate-notaryserver.sql
|
||||
fi
|
||||
if [ -n "${DB_USER_SIGNER}" -a $db = $DB_NAME_SIGNER ]; then
|
||||
echo "Granting access to database \"$db\" for user \"${DB_USER_SIGNER}\"..."
|
||||
mysql --defaults-file=/etc/mysql/debian.cnf \
|
||||
-e "GRANT ALL PRIVILEGES ON \`$db\`.* TO '${DB_USER_SIGNER}' IDENTIFIED BY '${DB_PASS_SIGNER}';"
|
||||
fi
|
||||
# Create our Database:
|
||||
mysql -uroot $db < ./initial.sql
|
||||
mysql -uroot $db < ./migrate.sql
|
||||
mysql -uroot $db < ./initial-notarysigner.sql
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue