full-stack-fastapi-template icon indicating copy to clipboard operation
full-stack-fastapi-template copied to clipboard

Is there a way to do local development without using Docker at all?

Open ihorm5 opened this issue 3 years ago • 4 comments

While working on Django projects, I typically use Docker only for deployment/CI/CD but locally using Docker slows down the development(Docker for Mac is terribly slow), and it is way more convenient to work without docker at all. After carefully reading README.md it appears that this template is supposed to be working only with Docker. Can anyone share their experience with using this template Dockerless?

ihorm5 avatar May 05 '22 11:05 ihorm5

Backend: in backend/app, create .env file(temp in THIS), then:

cd backend/app
poetry install
poetry run uvicorn app.main:app --reload
poetry run alembic revision --autogenerate -m "DO SOMETHING"
poetry run alembic upgrade head

dongfengweixiao avatar May 15 '22 11:05 dongfengweixiao

Thanks for the .env file, being able to run in local dev mode, also allows running/debugging tests through the IDE, which is very convenient/fast.

The tests involving the DB (all), were failing, so just mapped the PSQL port with:

  db:
    ports:
      - "8001:5432"

However the celery test, test_celery_worker_test still hangs up when run under local host, any ideas why ?

okz avatar Jul 21 '22 13:07 okz

Thanks for the .env file, being able to run in local dev mode, also allows running/debugging tests through the IDE, which is very convenient/fast.

The tests involving the DB (all), were failing, so just mapped the PSQL port with:

  db:
    ports:
      - "8001:5432"

However the celery test, test_celery_worker_test still hangs up when run under local host, any ideas why ?

Sorry, I have no idea.

dongfengweixiao avatar Jul 22 '22 02:07 dongfengweixiao

For anyone looking for the solution to this problem, you need to make the celery worker available to the host machine. You do that by adding

  queue:
    ports:
      - "8002:5672"  # RabbitMQ
      - "8003:15672"  # management interface

to docker-compose.override.yml. Don't forget to re-run docker-compose up -d.

Then you have to make the celery app configurable by adding

class Settings(BaseSettings):
    ....
    QUEUE_URL: str = "queue"

to config.py and changing celery_app.py:5 to

celery_app = Celery("worker", broker=f"amqp://guest@{settings.QUEUE_URL}//")

Finally, add to .env

QUEUE_URL=localhost:8002

petioptrv avatar Jul 19 '23 01:07 petioptrv