From a23c6ee8c6d24c0b1f8ab33b19278dcabd2e0c29 Mon Sep 17 00:00:00 2001 From: yixingj Date: Wed, 28 Jun 2017 15:45:16 +0800 Subject: [PATCH] Support include offline data on clair startup --- make/common/templates/clair/postgresql-init.d/README.md | 7 +++++++ make/docker-compose.clair.yml | 1 + make/prepare | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 make/common/templates/clair/postgresql-init.d/README.md diff --git a/make/common/templates/clair/postgresql-init.d/README.md b/make/common/templates/clair/postgresql-init.d/README.md new file mode 100644 index 000000000..b786ea8c6 --- /dev/null +++ b/make/common/templates/clair/postgresql-init.d/README.md @@ -0,0 +1,7 @@ +This folder used to run some initial sql for clair if needed. + +Just put the sql file in this directory and then start the +clair . + +both .sql and .gz format supported + diff --git a/make/docker-compose.clair.yml b/make/docker-compose.clair.yml index e99c9d28a..bb859d501 100644 --- a/make/docker-compose.clair.yml +++ b/make/docker-compose.clair.yml @@ -24,6 +24,7 @@ services: env_file: ./common/config/clair/postgres_env volumes: + - ./common/config/clair/postgresql-init.d/:/docker-entrypoint-initdb.d - /data/clair-db:/var/lib/postgresql/data logging: driver: "syslog" diff --git a/make/prepare b/make/prepare index 55144b897..42f4af71c 100755 --- a/make/prepare +++ b/make/prepare @@ -373,6 +373,10 @@ if args.clair_mode: pg_password = "password" clair_temp_dir = os.path.join(templates_dir, "clair") clair_config_dir = prep_conf_dir(config_dir, "clair") + print("Copying offline data file for clair DB") + if os.path.exists(os.path.join(clair_config_dir, "postgresql-init.d")): + shutil.rmtree(os.path.join(clair_config_dir, "postgresql-init.d")) + shutil.copytree(os.path.join(clair_temp_dir, "postgresql-init.d"), os.path.join(clair_config_dir, "postgresql-init.d")) postgres_env = os.path.join(clair_config_dir, "postgres_env") render(os.path.join(clair_temp_dir, "postgres_env"), postgres_env, password = pg_password) clair_conf = os.path.join(clair_config_dir, "config.yaml")