How to deploy with Docker Compose

Project structure:

backend
     -api
          -main.py
     -Dockerfile
     -requirements.txt
-Docker-compose.yaml
-Dockerfile.koyeb

I’m trying to deploy with docker-compose. The build settings I have as well as project structure are shown above. I have followed the directions suggested here. I’m unsure if I’m pointing to the Dockerfile.koyeb correctly which is in the parent directory of the working directory for the project. I’m using the relative pointer “…/Dockerfile.koyeb”. But I keep getting error:

#1 [internal] load build definition from ../Dockerfile.koyeb

18:12:12.331

#1 transferring dockerfile: 2B done

18:12:12.331

#1 DONE 0.0s

18:12:12.331

error: failed to solve: failed to read dockerfile: open ../Dockerfile.koyeb: no such file or directory

18:12:12.331

exit status 1

Can anyone understand what I’m doing wrong? The build works fine locally so my suspicion is it’s simply how I’m setting up the build process on Koyeb.

Hi @Kenneth_Liao,

If I understand your project structure correctly, you should try ./Dockerfile.koyeb.

Let me know

Thanks for the reply David. I updated the docker file location to ./Dockerfile.koyeb as you suggested but get the same error:

HEAD is now at 1fa9458 reverted to app directory
>> Moving content of subdirectory backend to /workspace
#1 [internal] load build definition from ./Dockerfile.koyeb
#1 transferring dockerfile: 2B done
#1 DONE 0.0s
error: failed to solve: failed to read dockerfile: open ./Dockerfile.koyeb: no such file or directory
exit status 1

For reference, here’s a screenshot of the actual project structure:
Screenshot 2024-06-11 at 2.27.51 PM

Am I correct that backend should be the working directory here? I’m trying to match what’s in the Dockerfile at

-backend
     -api
     -Dockerfile

where I set the working directory to:

# Use an official Python runtime as a parent image
FROM python:3.12

# Set the working directory in the container
WORKDIR /code

# 
COPY ./requirements.txt /code/requirements.txt

# 
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Copy the current directory contents into the container at /code
COPY ./api /code/api

# Run app.py when the container launches
CMD ["fastapi", "run", "api/main.py", "--host", "0.0.0.0", "--port", "80"]

UPDATE - I was able to get through the build by removing the override work directory option, so it should just be using the root folder of my repo. I kept the suggestion you made for dockerfile location: ./Dockerfile.koyeb. That got me through the build but then in the run I get this error:

Can you share the content of ./Dockerfile.koyeb?

FROM koyeb/docker-compose

COPY . /code

It should be:

FROM koyeb/docker-compose

COPY . /app