Add --port option to run-webapp. (#667)
K8s Deploy Test / Run deploy test suite (push) Failing after 3m1s
Details
Webapp Test / Run webapp test suite (push) Failing after 3m30s
Details
Smoke Test / Run basic test suite (push) Successful in 4m2s
Details
Publish / Build and publish (push) Successful in 58s
Details
Deploy Test / Run deploy test suite (push) Successful in 3m18s
Details
K8s Deploy Test / Run deploy test suite (push) Failing after 3m1s
Details
Webapp Test / Run webapp test suite (push) Failing after 3m30s
Details
Smoke Test / Run basic test suite (push) Successful in 4m2s
Details
Publish / Build and publish (push) Successful in 58s
Details
Deploy Test / Run deploy test suite (push) Successful in 3m18s
Details
* Add --port option to run-webapp * Fixed merge * lintpull/672/head v1.1.0-03a3645-202311291732
parent
113c0bfbf1
commit
03a3645b3c
|
|
@ -64,10 +64,10 @@ class DockerDeployer(Deployer):
|
||||||
except DockerException as e:
|
except DockerException as e:
|
||||||
raise DeployerException(e)
|
raise DeployerException(e)
|
||||||
|
|
||||||
def run(self, image: str, command=None, user=None, volumes=None, entrypoint=None, env={}, detach=False):
|
def run(self, image: str, command=None, user=None, volumes=None, entrypoint=None, env={}, ports=[], detach=False):
|
||||||
try:
|
try:
|
||||||
return self.docker.run(image=image, command=command, user=user, volumes=volumes,
|
return self.docker.run(image=image, command=command, user=user, volumes=volumes,
|
||||||
entrypoint=entrypoint, envs=env, detach=detach, publish_all=True)
|
entrypoint=entrypoint, envs=env, detach=detach, publish=ports, publish_all=len(ports) == 0)
|
||||||
except DockerException as e:
|
except DockerException as e:
|
||||||
raise DeployerException(e)
|
raise DeployerException(e)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class Deployer(ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def run(self, image: str, command=None, user=None, volumes=None, entrypoint=None, env={}, detach=False):
|
def run(self, image: str, command=None, user=None, volumes=None, entrypoint=None, env={}, ports=[], detach=False):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ class K8sDeployer(Deployer):
|
||||||
log_data = self.core_api.read_namespaced_pod_log(k8s_pod_name, namespace="default", container="test")
|
log_data = self.core_api.read_namespaced_pod_log(k8s_pod_name, namespace="default", container="test")
|
||||||
return log_stream_from_string(log_data)
|
return log_stream_from_string(log_data)
|
||||||
|
|
||||||
def run(self, image: str, command=None, user=None, volumes=None, entrypoint=None, env={}, detach=False):
|
def run(self, image: str, command=None, user=None, volumes=None, entrypoint=None, env={}, ports=[], detach=False):
|
||||||
# We need to figure out how to do this -- check why we're being called first
|
# We need to figure out how to do this -- check why we're being called first
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,16 @@ from dotenv import dotenv_values
|
||||||
from stack_orchestrator import constants
|
from stack_orchestrator import constants
|
||||||
from stack_orchestrator.deploy.deployer_factory import getDeployer
|
from stack_orchestrator.deploy.deployer_factory import getDeployer
|
||||||
|
|
||||||
|
WEBAPP_PORT = 3000
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--image", help="image to deploy", required=True)
|
@click.option("--image", help="image to deploy", required=True)
|
||||||
@click.option("--env-file", help="environment file for webapp")
|
@click.option("--env-file", help="environment file for webapp")
|
||||||
|
@click.option("--port", help="port to use (default random)")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def command(ctx, image, env_file):
|
def command(ctx, image, env_file, port):
|
||||||
'''build the specified webapp container'''
|
'''run the specified webapp container'''
|
||||||
|
|
||||||
env = {}
|
env = {}
|
||||||
if env_file:
|
if env_file:
|
||||||
|
|
@ -49,10 +52,13 @@ def command(ctx, image, env_file):
|
||||||
compose_project_name=cluster,
|
compose_project_name=cluster,
|
||||||
compose_env_file=None)
|
compose_env_file=None)
|
||||||
|
|
||||||
container = deployer.run(image, command=[], user=None, volumes=[], entrypoint=None, env=env, detach=True)
|
ports = []
|
||||||
|
if port:
|
||||||
|
ports = [(port, WEBAPP_PORT)]
|
||||||
|
container = deployer.run(image, command=[], user=None, volumes=[], entrypoint=None, env=env, ports=ports, detach=True)
|
||||||
|
|
||||||
# Make configurable?
|
# Make configurable?
|
||||||
webappPort = "3000/tcp"
|
webappPort = f"{WEBAPP_PORT}/tcp"
|
||||||
# TODO: This assumes a Docker container object...
|
# TODO: This assumes a Docker container object...
|
||||||
if webappPort in container.network_settings.ports:
|
if webappPort in container.network_settings.ports:
|
||||||
mapping = container.network_settings.ports[webappPort][0]
|
mapping = container.network_settings.ports[webappPort][0]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue