stocky-wire-60053
08/14/2022, 2:44 PMClientException: When networkMode=awsvpc, the host ports and container ports in port mappings must match
. (I'll post code in the reply as to not clutter here.)cluster = aws.ecs.Cluster("myapp-cluster")
repo = awsx.ecr.Repository("myapp-ecr")
image = awsx.ecr.Image("myapp", repository_url=repo.url, path="../")
lb = awsx.lb.ApplicationLoadBalancer("myapp-lb")
service = awsx.ecs.FargateService("myapp-service",
cluster=cluster.arn,
desired_count=2,
task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs(
container=awsx.ecs.TaskDefinitionContainerDefinitionArgs(
image=image.image_uri,
cpu=512,
memory=128,
essential=True,
port_mappings=[awsx.ecs.TaskDefinitionPortMappingArgs(
host_port=8080,
container_port=8080,
target_group=lb.default_target_group
)],
)
)
)
pulumi.export("url", lb.load_balancer.dns_name)
FROM python:3.9
RUN mkdir -p /myapp/src/myapp
COPY setup.cfg setup.py /myapp/
COPY src/ /myapp/src/
RUN python3 -m venv "/myapp/venv" \
&& /myapp/venv/bin/python -m pip install --upgrade pip \
&& /myapp/venv/bin/python -m pip install -e /myapp/
RUN chown root:root -R /myapp
RUN chown root:root -R /myapp/venv
EXPOSE 8080
ENV PATH="/myapp/venv/bin:$PATH"
CMD python -m uvicorn main:app --host 0.0.0.0 --port 8080 --app-dir /myapp/src/myapp/
billowy-army-68599
08/14/2022, 5:45 PMstocky-wire-60053
08/15/2022, 4:30 AMmost-jordan-25674
08/15/2022, 12:45 PMstocky-wire-60053
08/18/2022, 7:13 PM