61 lines
1.8 KiB
Python
Executable File
61 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# This code is a Qiskit project.
|
|
#
|
|
# (C) Copyright IBM 2023.
|
|
#
|
|
# This code is licensed under the Apache License, Version 2.0. You may
|
|
# obtain a copy of this license in the LICENSE file in the root directory
|
|
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
|
|
#
|
|
# Any modifications or derivative works of this code must retain this
|
|
# copyright notice, and modified files need to carry a notice indicating
|
|
# that they have been altered from the originals.
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Get the latest digest by running `docker pull icr.io/qc-open-source-docs-public/preview:latest`.
|
|
IMAGE_DIGEST = "sha256:2ad7c6dbdca288077ef1c752384edc578e5b42fe0b311c75b94ba1733b2b8529"
|
|
|
|
PWD = Path(__file__).parent
|
|
IMAGE = f"icr.io/qc-open-source-docs-public/preview@{IMAGE_DIGEST}"
|
|
|
|
|
|
def skip_apis() -> tuple[str]:
|
|
"""Mounts an empty directory to /docs/api/ to effectively exclude it"""
|
|
if "--apis" in sys.argv:
|
|
return ()
|
|
print("Skipping API docs for speed; use --apis to include them")
|
|
return ("-v", "/home/node/app/docs/api")
|
|
|
|
def main() -> None:
|
|
if "--pull-only" in sys.argv:
|
|
subprocess.run(["docker", "pull", IMAGE], check=True)
|
|
sys.exit(0)
|
|
|
|
# Keep this aligned with the Dockerfile at the root of the repository.
|
|
cmd = [
|
|
"docker",
|
|
"run",
|
|
"-v",
|
|
f"{PWD}/docs:/home/node/app/docs",
|
|
*skip_apis(),
|
|
"-v",
|
|
f"{PWD}/public:/home/node/app/packages/preview/public",
|
|
"-p",
|
|
"3000:3000",
|
|
# Needed for ctrl-c to shut down the container.
|
|
"--init",
|
|
"--rm",
|
|
IMAGE,
|
|
]
|
|
subprocess.run(cmd, check=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
main()
|
|
except KeyboardInterrupt:
|
|
pass
|