I'm having issues with deploying my agent to the c...
# cloud
g
I'm having issues with deploying my agent to the cloud. I copied the exact dockerfile from the documentation and yet I keep having this error: (agent-starter-python) PS C:\Users\3d3n2\agent-starter-python> lk agent deploy WARNING: config file C:\Users\3d3n2/.livekit/cli-config.yaml should have permissions 600 WARNING: config file C:\Users\3d3n2/.livekit/cli-config.yaml should have permissions 600 Using project [rzn-ai-demo] Using agent [CA_j9aShTjUWjBP] Uploading 100% [==============================] (1.8 MB/s) Updated agent [CA_j9aShTjUWjBP] [+] Building 22.7s (15/15) FINISHED => [internal] load remote build context 0.1s => copy /context / 0.0s => resolve image config for docker-image://docker.io/docker/dockerfile:1 0.1s => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:38387523653efa0039f8e1c89bb74a30504e76ee9f565e25c9a09841f9427b05 0.0s => => resolve docker.io/docker/dockerfile:1@sha256:38387523653efa0039f8e1c89bb74a30504e76ee9f565e25c9a09841f9427b05 0.0s => [internal] load metadata for ghcr.io/astral-sh/uv:python3.11-bookworm-slim 0.1s => [ 1/10] FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim@sha256:1c07cb9cae996d64f32093587506dc20e4ad952511c9f091caf378d89b1be351 0.0s => => resolve ghcr.io/astral-sh/uv:python3.11-bookworm-slim@sha256:1c07cb9cae996d64f32093587506dc20e4ad952511c9f091caf378d89b1be351 0.0s => CACHED [ 2/10] RUN adduser --disabled-password --gecos "" --home "/app" --shell "/sbin/nologin" --uid "10001" appuser 0.0s => CACHED [ 3/10] RUN apt-get update && apt-get install -y gcc python3-dev && rm -rf /var/lib/apt/lists/* 0.0s => CACHED [ 4/10] WORKDIR /app 0.0s => [ 5/10] COPY pyproject.toml uv.lock ./ 0.1s => [ 6/10] RUN mkdir -p src 0.1s => [ 7/10] RUN uv sync --locked 4.8s => [ 8/10] COPY . . 0.1s => [ 9/10] RUN chown -R appuser:appuser /app 15.9s => ERROR [10/10] RUN uv run src/agent.py download-files 0.8s ------ > [10/10] RUN uv run src/agent.py download-files: 0.149 Building agent-starter-python @ file:///app 0.770 Built agent-starter-python @ file:///app 0.772 Uninstalled 1 package in 0.41ms 0.772 Installed 1 package in 0.75ms 0.780 error: Failed to spawn:
src/agent.py
0.780 Caused by: No such file or directory (os error 2) ------ build failed for iad.ocir.io/axyci3pr8vxm/production-cloud-agents:p-3l8568mrvxk-ca-j9ashtjuwjbp-v20250822080759: failed to solve: process "/bin/sh -c uv run src/agent.py download-files" did not complete successfully: exit code: 2 (agent-starter-python) PS C:\Users\3d3n2\agent-starter-python>
c
I'm facing the same problem! agent works when deploying myself or using local but fails in livekit clopud with the same error
r
I am not super well versed on windows since I've not used it for a long time. You may have to map this to the windows equiv. The error message you are encountering indicates that the build process is failing at the step where it attempts to run the command
uv run src/agent.py download-files
. The specific error is
No such file or directory (os error 2)
, which suggests that the file
src/agent.py
does not exist in the expected location within the Docker container. Here are a few steps you can take to troubleshoot and resolve this issue: 1. Check File Paths: Ensure that the
src/agent.py
file is indeed located in the
src
directory relative to the Docker build context. The Dockerfile should have a
COPY
command that correctly copies the necessary files into the container. If your Dockerfile is similar to the one in the documentation, make sure that the
COPY
command is correctly set up to include the
src
directory. 2. Verify Dockerfile: If you are using a Dockerfile similar to the one provided in the documentation, ensure that it includes the necessary commands to copy your application files into the container. For example, the
COPY
command should look something like this:
Copy code
COPY . .
This command copies all files from the current directory into the working directory of the container. Make sure that your
src
directory is included in this context. 3. Check Build Context: When you run the
lk agent deploy
command, ensure that you are in the correct directory that contains the Dockerfile and the
src
directory. The build context should include all necessary files. 4. Permissions: The warning about the permissions for the config file (
C:\Users\3d3n2/.livekit/cli-config.yaml
) suggests that the file may not have the correct permissions. While this may not directly cause the build failure, it's good practice to ensure that the permissions are set correctly. You can change the permissions using:
Copy code
chmod 600 C:\Users\3d3n2/.livekit/cli-config.yaml
5. Inspect the Docker Image: If the build process is still failing, you can try running the Docker image interactively to inspect the filesystem and verify whether
src/agent.py
exists:
Copy code
docker run -it <your-image-name> /bin/sh
6. This will allow you to navigate the filesystem within the container and check for the presence of the
src/agent.py
file. If you continue to experience issues, please provide more details about your Dockerfile and the structure of your project directory. Notes: • Ensure that your Dockerfile is correctly set up to copy all necessary files into the container. • The error indicates a missing file, so verifying the file paths and build context is crucial. • The warning about the config file permissions may not be directly related to the build failure but should be addressed for best practices.
l
Does
src/agent.py
exist in your codebase? What is your entrypoint?
c
definitely the problem was windows, I run the same using WSL (ubuntu) in the same folder and worked
b
Same problem. ON windows.
WTH The file files are all empty. You guys are not copying the contents of the folder at all
I am pretty sure that the bug arises from the different slases being used on windows and linux in file paths. Livekit might be hard coded to linux slashes.
s
thanks for the report, investigating
very likely path separator issue
r
We have reproduced the issue and will fix in the tool. But in the mean-time on Windows the quick fix was the following: 1. move
.env
local &
agent.py
into root directory 2. remove
src/
in 2 locations at the bottom of the
Dockerfile
Depending on your setup you may only need to move
agent.py
as the env file is probably already in root in most cases.
s
Fix here and available in
v2.5.2
which is rolling out shortly to Homebrew and Winget
b
@strong-dress-64642 This problem is still not fully resolved. There are still inconsistencies between windows and linux. For some reason you guys are not copying the
.env.*
files in the src folder. This doesnt seem to be an issue when using wsl.
For some very odd reason this has something to do with .gitignore
s
You're intended to pass secrets into your cloud container via the native secrets manager, not with your source code. You can update them in existing container with
lk agent update-secrets
We strip all files in both .gitignore and .dockerignore before we upload your source
b
@strong-dress-64642 Yes, but the secrets passed via the CLI are only available at run time and not build time So the
RUN python src/main.py download-files
keeps failing as the
main.py
loads all my other modules and they all require the the env to be loaded otherwise they throw an error.
s
We don't support build secrets yet, this is a feature we're working on
You should not need secrets for your inference providers to run the
download-files
command
And it isn't necessary to pass your API keys manually into plugins, if that is why you're seeing failures. They will be read correctly from the env provided at runtime to the container
b
Yeah I understand that its not required to run the
download-files
but the way the code is usually structured forces me to. Yeah I am not really manually passing a lot of env variables, just some of my database and aws keys.
it would be nice if only
.dockerignore
was the one that was ignoring files. Its very counter intuitive to strip all the
.gitignore
files as well, but I understand why you guys do it.
Because I also have a google credentials file which is a
.json
file that cannot be passed via the secret. the
GOOGLE_APPLICATION_CREDENTIALS
just has the path of the
.json
file.
šŸ‘ 1
s
Yeah, unfortunately that is the state of things at the moment, but build secrets will be considered soon. Your db client crashes the moment it is imported if keys are not present?
b
@strong-dress-64642 Yeah, an error is throw is the Database url is not set. I prefer to keep it that way, so that it doesn't silently fail.
s
Interesting, yeah I forgot about Google json credentials. We will have to work that into build secrets implementation. Possible we need to allow all .gitignored files
šŸ‘ 1
e
Hey, any clue why is that happening? It fails at download-files when deploying with lk agent create
Copy code
=> [internal] load remote build context                                                                                                               2.6s
 => copy /context /                                                                                                                                    3.6s
 => [internal] load metadata for ghcr.io/astral-sh/uv:python3.13-bookworm-slim                                                                         0.2s
 => [ 1/10] FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim@sha256:efe2350aa848bc60720f136d94f47480095d8231b17547e4369f6bc97df59701                 0.0s
 => => resolve ghcr.io/astral-sh/uv:python3.13-bookworm-slim@sha256:efe2350aa848bc60720f136d94f47480095d8231b17547e4369f6bc97df59701                   0.0s
 => CACHED [ 2/10] RUN adduser     --disabled-password     --gecos ""     --home "/app"     --shell "/sbin/nologin"     --uid "10001"     appuser      0.0s
 => CACHED [ 3/10] RUN apt-get update && apt-get install -y     gcc     g++     python3-dev   && rm -rf /var/lib/apt/lists/*                           0.0s
 => CACHED [ 4/10] WORKDIR /app                                                                                                                        0.0s
 => CACHED [ 5/10] COPY pyproject.toml uv.lock ./                                                                                                      0.0s
 => CACHED [ 6/10] RUN mkdir -p src                                                                                                                    0.0s
 => CACHED [ 7/10] RUN uv sync --locked                                                                                                                0.0s
 => [ 8/10] COPY . .                                                                                                                                   6.8s
 => [ 9/10] RUN chown -R appuser:appuser /app                                                                                                         30.1s
 => ERROR [10/10] RUN uv run "src/agent.py" download-files                                                                                             0.2s
------
 > [10/10] RUN uv run "src/agent.py" download-files:
0.165 error: Failed to query Python interpreter at `/app/.venv/bin/python3`
0.165   Caused by: Exec format error (os error 8)
------
build failed for iad.ocir.io/axyci3pr8vxm/production-cloud-agents:p-4tr7wk3lnn7-ca-bauk2yngfuyp-v20250907160124: failed to solve: process "/bin/sh -c uv run \"src/agent.py\" download-files" did not complete successfully: exit code: 2
s
You should add
.venv
to your
.dockerignore
. you're uploading your virtual env and the container is trying to use all your local dependencies and binaries instead of what's appropriate for the target machine
This should also make uploads much faster
e
Ough! Makes sense, thanks!
s
No problem! Lmk if that works
e
@strong-dress-64642 It wasn't it, I actually did have .venv already added there
s
Are you on latest version of CLI? Can you try destroying and recreating agent deployment?
e
I did try deleting and recreating. Let me check the version..
That was on 2.5.3, updated to 2.5.5.. it worked like a charm. You are awesome. It would probably be helpful to get a warning inside the CLI when it's outdated or even auto-update it.
s
Totally! I'll make a note about update reminders! Sorry for the bugs, it's a moving target šŸ˜…
But glad that worked!
e
Thanks for your great work. If I have you here already, quick question. If I need agents to be pinned to eu region, I need to just contact your support team? (assuming I'm on scale plan)
s
We currently only support
us-east
for agent deployments, but the team is actively working on region pinning to any region where LiveKit already has SFU nodes. You'll just specify the region(s) you want in
livekit.toml
or via CLI parameter during deployment
šŸ‘Œ 1