fastapi/full-stack-fastapi-template

docker compose up not working

DungBuiDeveloper opened this issue · 18 comments

  • so many error when init project pleease check

https://github.com/bibektimilsina000/FastAPI-PgStarterKit
here is the working project if you only want backend part of this project

Just a heads up, I download this project recently and it worked for me without any modifications.

Hey @DungBuiDeveloper, I recently used the project and seems really smooth. I guess you need to explain what issues you face in the issue, so that we have a guide to help you with it.

I also could not just make it work out of the box. When I run docker compose up I get errors like the following

proxy-1 | 2024-08-10T00:27:21Z ERR github.com/traefik/traefik/v3/pkg/server/router/router.go:136 > error="middleware "full-stack-fastapi-project-www-redirect@docker" does not exist" entryPointName=https routerName=full-stack-fastapi-project-frontend-https@docker

proxy-1 | 2024-08-10T00:27:21Z ERR github.com/traefik/traefik/v3/cmd/traefik/traefik.go:355 > Router uses a non-existent certificate resolver certificateResolver=le routerName=full-stack-fastapi-project-adminer-https@docker

EDIT: these errors still persist, but a docker compose up --build creates a fresh build and works out of the box!

I have the same issue as you @emirakdere, sadly a simple docker compose up --build does not fix anything.

Same Problem here, already spent hours trying to figure out how to acces front & backend when I run Docker Compose - everything starts up, but they do not appear on localhost or localhost/api or localhost/docs as they should.

I have the same issue

The issue for me was not the template but my own system, I had Rancher Desktop running, which has its own instance of traefik running within the local kubernetes cluster. I switched off the kubernetes cluster and it worked out of the Box :)

I had it working out of the box, and I was really excited. But after I tried to add a new table and did an alembic migration i am now getting the same error as you! I have no idea what is going on. Does anybody have an idea how to fix this or even what is happening? I tried rolling things back but still no good.

I don't know what happened, but I managed to get rid of the error. Then I tried another database migration and now i'm back to the traefik errors again. This is really frustrating.

  • so many error when init project pleease check

did you guys follow the instruction,it may help

For now i'm developing locally. it was working just fine, but something happened when I tried to create a new database table that caused a catastrophic meltdown for my project. This error basically locked me out and i don't know why or how to reset. In the process I accidentally deleted my last alembic version before i finished downgrading to it. so, it's all a huge mess. two things that would really help me out:

  1. is there an easy way to just completely reset the database and then bring it back up to the last version file?
  2. is there a way to auto generate a table and all the associated crud on the back end? Some php or ruby frameworks have a cli tool that does all that for you. right now i have to touch about 6 files and I can't keep track of it all.

Any help here would be awesome. I struggle with all of this docker and dev ops stuff.

I managed to get the server running again somehow this morning and began making progress again. However, I changed something in the docker configuration to add an additional host, and the entire thing fell apart. It won't build, the backend won't run, and i can't track down the issue.

This framework looked really promising, but I have to say that the back-end with docker is brutal. I have no idea how to get it started back up again. I've reverted everything back, I've tried to upgrade the database head, i've deleted the docker containers and volumes, i've tried to do a --build. This framework works really well until it just doesn't. If anybody has any tips on this, docker is not my strong suit. I'm working in the development environment on windows 11. i'm running the backend in docker and then i'm running npm build dev so I can work locally.

2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z DBG github.com/traefik/traefik/v3/pkg/middlewares/recovery/recovery.go:22 > Creating middleware entryPointName=https middlewareName=traefik-internal-recovery middlewareType=Recovery
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z DBG github.com/traefik/traefik/v3/pkg/server/router/tcp/manager.go:237 > Adding route for adminer.localhost with TLS options default entryPointName=https
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z DBG github.com/traefik/traefik/v3/pkg/server/router/tcp/manager.go:237 > Adding route for localhost with TLS options default entryPointName=https
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z DBG github.com/traefik/traefik/v3/pkg/server/router/tcp/manager.go:237 > Adding route for www.localhost with TLS options default entryPointName=https
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z ERR github.com/traefik/traefik/v3/cmd/traefik/traefik.go:355 > Router uses a non-existent certificate resolver certificateResolver=le routerName=full-stack-fastapi-project-adminer-https@docker
2024-08-31 10:11:37 proxy-1 | 2024-08-31T15:11:37Z ERR github.com/traefik/traefik/v3/cmd/traefik/traefik.go:355 > Router uses a non-existent certificate resolver certificateResolver=le routerName=full-stack-fastapi-project-backend-https@docker

I can't even get a fresh install from the repository working now. I have no idea.

  1. clone repository
  2. copy the .env file to the backend directory
  3. npm install in the front end directory
  4. poetry install in the backend directory
  5. docker compose up -d

what am i missing here. I'm completely shut out in a local dev environment. Has anybody else experienced this?

same issue for me!

Good evening everyone,

After facing this error, which suddenly appeared without clear explanation, I decided to start from scratch. Below is my approach:

First, I recommend watching Tiangolo’s video, which explains how to set up Traefik with a FastAPI server and its own Docker image: "FROM tiangolo/uvicorn-gunicorn-fastapi.10."

https://www.youtube.com/watch?v=7N5O62FjGDc

Next, while looking at my proxy logs more closely, the first warning/error I noticed was that it couldn't find the network "traefik-public." In the production config, you need to first run docker network create traefik-public and then use it as external: true. In the development config, it was set up with external: false, but strangely, it wasn't working anymore.

Finally, I switched the network to driver: bridge in the docker-compose.yml file.

networks:
  traefik-public:
    driver: bridge

Then I realized that while using this template, I had changed the stack name and forgot to update the "STACK_NAME" environment variable. I eventually removed the STACK_NAME from the docker-compose.yml and added a container_name for each service.

adminer:
    container_name: adminer
    image: adminer
    restart:...

OLD: - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-http.rule=Host('adminer.${DOMAIN?Variable not set}')

NEW: - traefik.http.routers.adminer-http.rule=Host('adminer.${DOMAIN?Variable not set}')

After that, I noticed that the lines - traefik.constraint-label=traefik-public were incorrect. By running docker inspect backend, I found that the network name used by my containers was "my-project_traefik-public", where "my-project" is the folder name where I used this template. So, I replaced all the constraint-labels with my actual network name.

There you go, enjoy debugging! Stay strong everyone!

It works! Thanks @MP242