Customize path for a port
For any service we can customize path for the port in the following ways:
Customize path using UI
We can customize path simply by simply adding the path in the Port
section under Endpoint
as follows:
- For Path based routing:

- For path + sub-domain based routing

Customize path using CLI
We can add path to a port
of the service
in the Python as well as YAML.
Here is an example where we add path to a app running on port 8000.
from servicefoundry import Build, Service, Port, BasicAuthCreds, GitSource, DockerFileBuild
svc = Service(
name="fastapi",
image=Build(
build_source=GitSource(
repo_url="https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker",
branch_name="master",
ref="01201e19470c1da7618fa9ab361fe7e5d041b147"
),
build_spec=DockerFileBuild(
dockerfile_path="./docker-images/python3.11-slim.dockerfile",
build_context_path="./docker-images/"
)
),
env={"PORT": 8000},
ports=[
Port(
port=8000,
host="fastapi-my-workspace-8000.truefoundry.my-org.com",
path="abc"
)
]
)
type: service
name: testing
image:
type: build
build_source:
type: git
repo_url: https://github.com/qaifi-tf/service-example
branch_name: main
ref: b284172b5fef26ea188bbe06bd7efb54676d08b4
build_spec:
type: dockerfile
dockerfile_path: ./Dockerfile
build_context_path: ./
docker_registry: user-truefoundry:devtest-euwe1-ecr
ports:
- port: 8000
expose: true
protocol: TCP
app_protocol: http
path: /abc/
host: truefoundry.tfy-ctl-euwe1-devtest.devtest.truefoundry.tech
replicas: 1
resources:
cpu_request: 0.2
cpu_limit: 0.5
memory_request: 200
memory_limit: 500
ephemeral_storage_request: 1000
ephemeral_storage_limit: 2000
The only change we have made is adding the path
argument to Port
.
Port(host="...", path="/abc/", ...)
ports:
- ...
path: /abc/
Updated 19 days ago