コード例 #1
0
    def run(self):

        # Get the docker client.
        docker_client = docker.from_env()

        # Determine the app.
        app = self.options["<app>"]
        if app is not None:

            # Check it.
            if App.check(docker_client, app):
                logger.info("({}) Is valid and ready to go!".format(app))

        else:

            # Check all apps.
            stack_valid = True
            apps = App.get_apps()
            for app in apps:

                # Check the app.
                if App.check(docker_client, app):
                    logger.info("({}) Is valid and ready to go!".format(app))

                else:
                    stack_valid = False

            if stack_valid:
                logger.info("The Stack is valid and ready to go!")
            else:
                logger.critical(
                    "Stack invalid! Ensure all paths and images are "
                    "correct and try again")
コード例 #2
0
    def run(self):

        # Get the docker client.
        docker_client = docker.from_env()

        # Check it.
        if not App.check(docker_client):
            logger.critical(
                "Stack is invalid! Ensure all paths and images are correct"
                " and try again")
            return

        # Check for clean.
        if self.options["--clean"]:

            App.clean_images(docker_client)

        # Iterate through built apps
        for app in App.get_built_apps():
            App.build(app)

        # Build the command.
        command = ["docker-compose", "up"]

        # Check for the daemon flag.
        if self.options["-d"]:
            command.append("-d")

        # Check for flags
        if self.options.get("<flags>"):

            # Split them, append the '--' and add them to the command
            for flag in self.options.get("<flags>").split(","):
                command.append("-{}".format(flag) if len(flag) ==
                               1 else "--{}".format(flag))

        # Run the pre-build hook, if any
        Stack.hook("pre-up")

        # Capture and redirect output.
        logger.debug("Running docker-compose up...")

        Stack.run(command)

        # Run the pre-build hook, if any
        Stack.hook("post-up")