Giter Club home page Giter Club logo

whythawk / full-stack-fastapi-postgresql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tiangolo/full-stack-fastapi-template

224.0 224.0 48.0 2.73 MB

Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Nuxt3, Docker, automatic HTTPS and more.

License: MIT License

Shell 2.05% Python 35.33% Mako 0.18% HTML 13.10% Dockerfile 1.86% JavaScript 0.22% Vue 34.58% TypeScript 12.63% CSS 0.05%
celery cookiecutter docker fastapi magic-link-authentication neo4j nuxt3 postgresql python sqlalchemy totp

full-stack-fastapi-postgresql's People

Contributors

abhisheksms avatar airibarne avatar ashears avatar br3ndonland avatar daniel-butler avatar dmontagu avatar ebreton avatar franzforstmayr avatar gucharbon avatar jcaguirre89 avatar mocsar avatar mpclarkson avatar nonameentered avatar rcheese avatar rlonka avatar stephenbrown2 avatar tiangolo avatar turukawa avatar vusa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

full-stack-fastapi-postgresql's Issues

No schema for ItemCreate

There is an import in tests but no definition in code.

git:(main) ✗ docker-compose exec backend bash
root@eedc12fd4540:/app# ls
alembic  alembic.ini  app  imports  inboard  mypy.ini  poetry.lock  poetry.toml  prestart.sh  pyproject.toml  scripts  tests-start.sh  worker-start.sh
root@eedc12fd4540:/app# py.test
=========================================================================================== test session starts ============================================================================================
platform linux -- Python 3.9.15, pytest-7.2.1, pluggy-1.0.0
rootdir: /app
plugins: anyio-3.6.2, cov-4.0.0
collected 19 items / 2 errors

================================================================================================== ERRORS ==================================================================================================
___________________________________________________________________________ ERROR collecting app/tests/api/api_v1/test_items.py ____________________________________________________________________________
ImportError while importing test module '/app/app/tests/api/api_v1/test_items.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
app/tests/api/api_v1/test_items.py:5: in <module>
    from app.tests.utils.item import create_random_item
app/tests/utils/item.py:6: in <module>
    from app.schemas.item import ItemCreate
E   ModuleNotFoundError: No module named 'app.schemas.item'
_______________________________________________________________________________ ERROR collecting app/tests/crud/test_item.py _______________________________________________________________________________
ImportError while importing test module '/app/app/tests/crud/test_item.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
app/tests/crud/test_item.py:4: in <module>
    from app.schemas.item import ItemCreate, ItemUpdate
E   ModuleNotFoundError: No module named 'app.schemas.item'
============================================================================================= warnings summary =============================================================================================
.venv/lib/python3.9/site-packages/pkg_resources/__init__.py:121
  /app/.venv/lib/python3.9/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
    warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================================= short test summary info ==========================================================================================
ERROR app/tests/api/api_v1/test_items.py
ERROR app/tests/crud/test_item.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================================= 1 warning, 2 errors in 1.93s =======================================================================================
root@eedc12fd4540:/app#

Documentation improvement to reduce verbosity and visual span

First of all, congratulations 🥳 ! This is by far the best repository I have seen in a long time. I really expected to have something similar while developing my first FastAPI boilerplate.

My suggestion may sound somewhat junior-level, please, do not judge me. BUT I like to have changes and actions STRICTLY CLEAR, which your documentation succeeds, in a verbose mode, which maybe well for someone with more experience. Do not take me wrong, but this repository would benefit from collapsable components to summarize the documentation, like I helped with here, particularly this page. Also, explicit citations on where to perform customization, like the cookiecutter.json, pointers of what to read and why for the very beginning is very appreciated (these instructions appears on advanced mathematics textbooks).

I can suggest my own changes as a pull request if you like, but I need your thumbs up first.

Take a look at my fork repo:

  1. Main README https://github.com/trouchet/full-stack-fastapi-postgresql
  2. Project README: https://github.com/trouchet/full-stack-fastapi-postgresql/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/README.md

Anyhow, once more CONGRATULATIONS AND THANKS FOR THIS REPOSITORY! 🥳

Some more found issues

  1. Vite trying to connect with Nuxt on port 24678 for hot reloading code changes – spamming webconsole log and don't work. Need expose in docker-compose.override.yml
    ports:

    • "24678:24678"
  2. Content loading in Nuxt don't work because of Nuxt do request on /api/_content but it routed by traefik on backend instead of frontend.
    I change PathPrefix(/api) to PathPrefix(/api/v) in docker-compose.override.yml of backend setting. Now /api/ will route to frontend.

  3. When trying register with only an email by magic link, it failed:
    File "/app/app/crud/crud_user.py", line 19, in create
    hashed_password=get_password_hash(obj_in.password),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    because password don't exist. Some fix:
    hashed_password=get_password_hash(obj_in.password) if obj_in.password is not None else None,

Hope this help fix some bugs.

Running into issues on M1 MacBook

Greetings,

first of all I want to say thank you for this clean project, I absolutely fell in love with the used technologies again and appreciate the effort very much.

After cloning the project, copying my .env file and ultimately running docker compose up I've ran into some errors, which I will list down below:

Overall I faced some issues, which apparently were caused by M1 builds not yet being correct - this was fixable by using the recommended solution in the StackOverflow post seen above: Changing the docker platform back to amd64 (export DOCKER_DEFAULT_PLATFORM=linux/amd64) and running it via Rosetta.

The Backend seems to work perfectly fine now (Entered the Swagger docs and tried some stuff), however I can't seem to get the frontend to work properly: Requests are being made, however keep failing

ient.ts:324     GET http://localhost:24678/_nuxt/ net::ERR_CONNECTION_REFUSED

Even though the page is properly getting displayed, this keeps occurring and requests to the backend do not get properly sent to the backend, however rather the responses contain HTML.

Thanks for reading and helping out,

Cheers!

Login Failed

When trying to login with my superuser credentials in my fresh build application I get an login error in tokens.ts/usTokenStore.getTokens().

The error is visible as toast in frontend, no error shown in docker-compose logs -f.

ERROR:__main__:(psycopg2.OperationalError) could not translate host name "db" to address

I followed all instructions in the development-guide however when running docker-compose I run into this error:

test-celeryworker-1 | ERROR:main:(psycopg2.OperationalError) could not translate host name "db" to address: Temporary failure in name resolution
test-celeryworker-1 |
test-celeryworker-1 | (Background on this error at: https://sqlalche.me/e/20/e3q8)
test-celeryworker-1 | WARNING:main:Finished call to 'main.init' after 26.012(s), this was the 3rd time calling it.
test-celeryworker-1 |
test-celeryworker-1 | INFO:main:Starting call to 'main.init', this is the 4th time calling it.
test-backend-1 | ERROR:main:(psycopg2.OperationalError) could not translate host name "db" to address: Temporary failure in name resolution
test-backend-1 |
test-backend-1 | (Background on this error at: https://sqlalche.me/e/14/e3q8)
test-backend-1 | WARNING:main:Finished call to 'main.init' after 35.030(s), this was the 4th time calling it.
test-backend-1 |
test-backend-1 | INFO:main:Starting call to 'main.init', this is the 5th time calling it.

Poetry problems

Any attempt at using poetry add, causes a The lock file is not compatible with the current version of Poetry error when building docker.
I'm using poetry 1.4.0

OAuth2PasswordBearer endpoint wrongly defined?

Greetings,

while accessing the Swagger UI docs, I realized that the endpoint that's being used for user/password authentication is called /oauth, however in the code this can be found:
reusable_oauth2 = OAuth2PasswordBearer(tokenUrl=f"{settings.API_V1_STR}/login/access-token")

When trying to login via the "Login" button in Swagger UI, a 404 Not Found is being returned - after changing the access-token occurrences in the code to oauth e.g.
reusable_oauth2 = OAuth2PasswordBearer(tokenUrl=f"{settings.API_V1_STR}/login/oauth") the login in the Swagger UI works.

Thanks for reading and maintaining,

Cheers!

Sending email with SSL/TLS does not work

Hello,

After several attempts, I couldn't configure the emails to receive them correctly with a common SMTP configuration with SSL on.

Steps to reproduce.

  1. pip install cookiecutter
  2. cookiecutter https://github.com/whythawk/full-stack-fastapi-postgresql
  3. Add a SMTP configuration (==> add SMTP_TLS=True in .env by default)
  4. docker-compose up
  5. Try to send a magic link or a reset password email.
    => Nothing happen.

After few research, I find out that the configuration inside backend (utilities) is not correct.
See python-emails documentation here: https://python-emails.readthedocs.io/en/latest/
Must replace tls by ssl inside the file.

Do you see a better idea?

Build error project

i am language not good, thank your support
when i build docker not running all
it is my docker container
image

and pgadmin can't login
image

bu when i connect with navicat it connected good

image

is my .env

DOMAIN=localhost

DOMAIN=local.dockertoolbox.tiangolo.com

DOMAIN=localhost.tiangolo.com

DOMAIN=dev.thien.com

STACK_NAME=thien-com

TRAEFIK_PUBLIC_NETWORK=traefik-public
TRAEFIK_TAG=thien.com
TRAEFIK_PUBLIC_TAG=traefik-public

DOCKER_IMAGE_BACKEND=backend
DOCKER_IMAGE_CELERYWORKER=celeryworker
DOCKER_IMAGE_FRONTEND=frontend

Backend

BACKEND_APP_MODULE=app.main:app
BACKEND_CORS_ORIGINS=http://localhost:4200
BACKEND_PRE_START_PATH=/app/prestart.sh
PROJECT_NAME=thien
SECRET_KEY=190c2051bcd209ae63c0e81c282caf4442392a610535f39aa5bb9eda31921e1a
TOTP_SECRET_KEY=changethis
FIRST_SUPERUSER=[email protected]
FIRST_SUPERUSER_PASSWORD=Admin@123
SMTP_TLS=True
SMTP_PORT=587
SMTP_HOST=
SMTP_USER=
SMTP_PASSWORD=
EMAILS_FROM_EMAIL=[email protected]
EMAILS_FROM_NAME=Symona Adaro
EMAILS_TO_EMAIL=[email protected]

USERS_OPEN_REGISTRATION=True

SENTRY_DSN=

Flower

FLOWER_BASIC_AUTH=admin:Admin@123

Postgres

POSTGRES_SERVER=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=changethis
POSTGRES_DB=app

PgAdmin

PGADMIN_LISTEN_PORT=5050
PGADMIN_DEFAULT_EMAIL=[email protected]
PGADMIN_DEFAULT_PASSWORD=Admin@123

Neo4j

NEO4J_SERVER=neo4j
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=changethis
NEO4J_AUTH=neo4j:changethis
NEO4J_BOLT=bolt

No Let's Encrypt Certificate for base domain

Firstly, thank you for publishing this amazing project.

Currently, I am trying to deploy the project to a digital ocean droplet. I can access services like pgadmin, traefik and flower; however, on the base domain, I am missing a let's encrypt certificate (instead I am issued a traefik default cert).

Am I missing a configuration step besides the ones listed in the excellent deployment documentation? Or should the frontend and backend containers be part of the traefik netwok as well?

Thank you.

Nested model list

Hello and thanks again for this marvellous stack !

I am trying to integrate a nested model and return a list.

This works fine for a single object, but not lists.

For example, simply adding "owner: User" to schemas in a related table returns the appropriate owner with related schema.

But I get "value is not a valid list (type=type_error.list)" if I try something such as "itemsRelation: list[ItemsSchema]".

The response returns a list and works well individually, but perhaps not in the correct format.

I will send a pull request for items table and related tests once this is running.

Thank you.

Change tokenUrl

Hi !

Thanks you for amazing contribution :)

I just found that we need to change app/api/deps/

reusable_oauth2 = OAuth2PasswordBearer(tokenUrl=f"(tokenUrl=f"{settings.API_V1_STR}/login/access-token")
->
reusable_oauth2 = OAuth2PasswordBearer(tokenUrl=f"{settings.API_V1_STR}/login/oauth")

Whatelse it will throw error in swagger authentication

500 [VITE_ERROR] /pages/[...slug].vue?macro=true

The build works fine, when I go to http://localhost get this:

[vite-node] [plugin:vite:vue] [VITE_ERROR] /pages/[...slug].vue?macro=true

<template>
    <main class="max-w-none mx-auto sm:w-3/5 prose prose-reader-light prose-reader-base prose-reader-compact px-4 pt-10 pb-20 sm:px-6">
        <ContentDoc />
    </main>
</template>

<script setup lang="ts">
definePageMeta({
  middleware: ["refresh"],
});
</script>
  

at /pages/[...slug].vue?macro=true

build error

Good day, after

  1. docker-compose build --no-cache
  2. i have this error:
[celeryworker:latest  5/11] RUN bash -c "if [ true == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi":
#0 0.563 Skipping virtualenv creation, as specified in config file.
#0 0.695 Installing dependencies from lock file
#0 1.183 
#0 1.183 Package operations: 93 installs, 1 update, 0 removals
#0 1.183 
#0 1.184   • Installing idna (3.4)
#0 1.184   • Installing sniffio (1.3.0)
#0 3.443   • Installing anyio (3.6.2)
#0 3.446   • Installing certifi (2022.12.7)
#0 3.449   • Installing charset-normalizer (2.1.1)
#0 3.451   • Installing typing-extensions (4.4.0)
#0 3.451   • Installing pycparser (2.21)
#0 3.461   • Installing urllib3 (1.26.13)
#0 3.461   • Installing vine (5.0.0)
#0 3.463   • Installing wcwidth (0.2.5)
#0 5.971   • Installing amqp (5.1.1)
#0 5.974   • Installing asgiref (3.5.2)
#0 5.975   • Installing cachetools (5.2.0)
#0 5.978   • Installing click (8.1.3)
#0 5.980   • Installing cffi (1.15.1)
#0 5.982   • Installing attrs (22.1.0)
#0 5.984   • Installing cssselect (1.2.0)
#0 5.985   • Installing cssutils (2.6.0)
#0 7.980   • Installing exceptiongroup (1.0.4)
#0 8.755   • Installing greenlet (2.0.1)
#0 9.152   • Installing h11 (0.14.0)
#0 9.401   • Installing iniconfig (1.1.1)
#0 9.402   • Installing httptools (0.5.0)
#0 9.408   • Installing lxml (4.9.2)
#0 10.04   • Installing markupsafe (2.1.1)
#0 10.52   • Installing packaging (22.0)
#0 11.48   • Installing pluggy (1.0.0)
#0 13.67   • Installing prompt-toolkit (3.0.36)
#0 13.87   • Installing pyasn1 (0.4.8)
#0 13.92   • Installing pydantic (1.10.2)
#0 13.95   • Installing python-dotenv (0.21.0)
#0 14.40   • Installing pytz (2022.6)
#0 15.09   • Installing pyyaml (6.0)
#0 15.09   • Installing requests (2.28.1)
#0 16.68   • Updating setuptools (58.1.0 -> 65.6.3)
#0 17.80   • Installing six (1.16.0)
#0 18.40   • Installing starlette (0.22.0)
#0 19.65   • Installing tomli (2.0.1)
#0 19.72   • Installing uvloop (0.17.0)
#0 19.93   • Installing watchgod (0.8.2)
#0 20.36   • Installing websockets (10.4)
#0 23.49   • Installing bcrypt (4.0.1)
#0 23.51   • Installing billiard (3.6.4.0)
#0 23.51   • Installing chardet (5.1.0)
#0 23.51   • Installing click-didyoumean (0.3.0)
#0 23.51   • Installing click-plugins (1.1.1)
#0 23.52   • Installing click-repl (0.2.0)
#0 23.52   • Installing coverage (6.5.0)
#0 23.52   • Installing cryptography (38.0.4)
#0 27.73   • Installing dnspython (2.2.1)
#0 27.86   • Installing ecdsa (0.18.0)
#0 27.91   • Installing fastapi (0.88.0)
#0 28.41   • Installing gunicorn (20.1.0)
#0 28.54   • Installing httpcore (0.16.2)
#0 29.06   • Installing kombu (5.2.4)
#0 29.24   • Installing mako (1.2.4)
#0 30.46   • Installing mccabe (0.7.0)
#0 32.90   • Installing mypy-extensions (0.4.3)
#0 33.62   • Installing neo4j-driver (4.3.6)
#0 34.08   • Installing neobolt (1.7.17)
#0 34.09   • Installing pathspec (0.10.3)
#0 34.49   • Installing platformdirs (2.6.0)
#0 37.37   • Installing premailer (3.10.0)
#0 37.69   • Installing psycopg2-binary (2.9.5)
#0 38.09   • Installing pycodestyle (2.10.0)
#0 38.83   • Installing pyflakes (3.0.1)
#0 39.50   • Installing pytest (7.2.0)
#0 40.08   • Installing python-dateutil (2.8.2)
#0 41.08   • Installing rfc3986 (1.5.0)
#0 42.26   • Installing rsa (4.9)
#0 42.71   • Installing shapely (1.7.1)
#0 45.01   • Installing sqlalchemy (1.4.45)
#0 45.04   • Installing uvicorn (0.17.6)
#0 55.46 
#0 55.46   CalledProcessError
#0 55.46 
#0 55.46   Command '['/usr/local/bin/python3.9', '-m', 'pip', 'install', '--use-pep517', '--disable-pip-version-check', '--isolated', '--no-input', '--prefix', '/usr/local', '--no-deps', '/root/.cache/pypoetry/artifacts/a3/87/7e/624f3c03cf53f002423bb5de2a949525887c473c12c523741db0e80fb6/Shapely-1.7.1.tar.gz']' returned non-zero exit status 1.
#0 55.46 
#0 55.46   at /usr/local/lib/python3.9/subprocess.py:528 in run
#0 55.63        524│             # We don't call process.wait() as .__exit__ does that for us.
#0 55.63        525│             raise
#0 55.63        526│         retcode = process.poll()
#0 55.63        527│         if check and retcode:
#0 55.63     →  528│             raise CalledProcessError(retcode, process.args,
#0 55.63        529│                                      output=stdout, stderr=stderr)
#0 55.64        530│     return CompletedProcess(process.args, retcode, stdout, stderr)
#0 55.64        531│ 
#0 55.64        532│ 
#0 55.64 
#0 55.64 The following error occurred when trying to handle this error:
#0 55.64 
#0 55.64 
#0 55.64   EnvCommandError
#0 55.64 
#0 55.64   Command ['/usr/local/bin/python3.9', '-m', 'pip', 'install', '--use-pep517', '--disable-pip-version-check', '--isolated', '--no-input', '--prefix', '/usr/local', '--no-deps', '/root/.cache/pypoetry/artifacts/a3/87/7e/624f3c03cf53f002423bb5de2a949525887c473c12c523741db0e80fb6/Shapely-1.7.1.tar.gz'] errored with the following return code 1, and output: 
#0 55.64   Processing /root/.cache/pypoetry/artifacts/a3/87/7e/624f3c03cf53f002423bb5de2a949525887c473c12c523741db0e80fb6/Shapely-1.7.1.tar.gz
#0 55.64     Installing build dependencies: started
#0 55.64     Installing build dependencies: finished with status 'done'
#0 55.64     Getting requirements to build wheel: started
#0 55.64     Getting requirements to build wheel: finished with status 'error'
#0 55.64     error: subprocess-exited-with-error
#0 55.64     
#0 55.64     × Getting requirements to build wheel did not run successfully.
#0 55.64     │ exit code: 1
#0 55.64     ╰─> [23 lines of output]
#0 55.64         Failed `CDLL(libgeos_c.so.1)`
#0 55.64         Failed `CDLL(libgeos_c.so)`
#0 55.64         Traceback (most recent call last):
#0 55.64           File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
#0 55.64             main()
#0 55.64           File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
#0 55.64             json_out['return_val'] = hook(**hook_input['kwargs'])
#0 55.64           File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
#0 55.64             return hook(config_settings)
#0 55.64           File "/tmp/pip-build-env-0u4intvk/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
#0 55.64             return self._get_build_requires(config_settings, requirements=['wheel'])
#0 55.64           File "/tmp/pip-build-env-0u4intvk/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
#0 55.64             self.run_setup()
#0 55.64           File "/tmp/pip-build-env-0u4intvk/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 484, in run_setup
#0 55.64             super(_BuildMetaLegacyBackend,
#0 55.64           File "/tmp/pip-build-env-0u4intvk/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 335, in run_setup
#0 55.64             exec(code, locals())
#0 55.64           File "<string>", line 85, in <module>
#0 55.64           File "/tmp/pip-req-build-w65g7_04/shapely/_buildcfg.py", line 169, in <module>
#0 55.64             lgeos = load_dll('geos_c',
#0 55.64           File "/tmp/pip-req-build-w65g7_04/shapely/_buildcfg.py", line 162, in load_dll
#0 55.64             raise OSError(
#0 55.64         OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']
#0 55.64         [end of output]
#0 55.64     
#0 55.64     note: This error originates from a subprocess, and is likely not a problem with pip.
#0 55.64   error: subprocess-exited-with-error
#0 55.64   
#0 55.64   × Getting requirements to build wheel did not run successfully.
#0 55.64   │ exit code: 1
#0 55.64   ╰─> See above for output.
#0 55.64   
#0 55.64   note: This error originates from a subprocess, and is likely not a problem with pip.
#0 55.64   
#0 55.64 
#0 55.64   at /opt/poetry/venv/lib/python3.9/site-packages/poetry/utils/env.py:1540 in _run
#0 55.75       1536│                 output = subprocess.check_output(
#0 55.75       1537│                     command, stderr=subprocess.STDOUT, env=env, **kwargs
#0 55.75       1538│                 )
#0 55.75       1539│         except CalledProcessError as e:
#0 55.75     → 1540│             raise EnvCommandError(e, input=input_)
#0 55.75       1541│ 
#0 55.75       1542│         return decode(output)
#0 55.75       1543│ 
#0 55.75       1544│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:
#0 55.75 
#0 55.75 The following error occurred when trying to handle this error:
#0 55.75 
#0 55.75 
#0 55.75   PoetryException
#0 55.75 
#0 55.75   Failed to install /root/.cache/pypoetry/artifacts/a3/87/7e/624f3c03cf53f002423bb5de2a949525887c473c12c523741db0e80fb6/Shapely-1.7.1.tar.gz
#0 55.75 
#0 55.75   at /opt/poetry/venv/lib/python3.9/site-packages/poetry/utils/pip.py:58 in pip_install
#0 55.76        54│ 
#0 55.76        55│     try:
#0 55.76        56│         return environment.run_pip(*args)
#0 55.76        57│     except EnvCommandError as e:
#0 55.76     →  58│         raise PoetryException(f"Failed to install {path.as_posix()}") from e
#0 55.76        59│ 
#0 55.76 
------
failed to solve: executor failed running [/bin/sh -c bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"]: exit code: 1

MacOS 13.1

Front end won't start because nuxt not found

Hi There,

First, thanks SO much for this repo, it's a huge help!

The backend starts nicely, but the frontend container fails with the following ...

**docker logs my-app-frontend-1**
yarn run v1.22.19
$ nuxt dev
/bin/sh: 1: nuxt: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I saw no errors with the docker build and start.

Thanks!

Build does not complete - variables not set in docker-compose.yml?

I am trying to get this to run on my local development machine (Intel MacBook Pro, Docker Desktop), but although the cookiecutter completes correctly, the docker-compose build --no-cache fails with the following error message:

=> [auth] library/node:pull token for registry-1.docker.io                                                                                                                                  0.0s
failed to receive status: rpc error: code = Unavailable desc = error reading from server: EOF

Checking the docker-compose.yml file, I see a lot of Variable not set mentions - see attached file which I had to rename to .txt).

Any ideas how I can debug this?

docker-compose.txt

Pytest issues

Been having a ton of trouble running the scripts/test-local.sh as instructed in the README. I keep running into ModulenotFoundError issues in backend/app/app/tests/conftest.py I've confirmed the following are working:

  1. My backend Docker container is copying over backend/app to /app as expected.
  2. /app is getting set as the Python path as expected.
  3. Imports work normally when bash'd into the backend container.
  4. Imports work normally when running the backend service.
  5. sys.path contains /app as expected (I print it out while running pytest -s).

However, no matter how I seem to run pytest (bash'd into the backend service, docker compose run backend pytest, or the test-local.sh script), I get the following error:

==================================================================================================== ERRORS ====================================================================================================
________________________________________________________________________________________ ERROR collecting test session _________________________________________________________________________________________
/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py:641: in _importconftest
    mod = import_path(conftestpath, mode=importmode, root=rootpath)
/usr/local/lib/python3.10/site-packages/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/local/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1050: in _gcd_import
    ???
<frozen importlib._bootstrap>:1027: in _find_and_load
    ???
<frozen importlib._bootstrap>:1006: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:688: in _load_unlocked
    ???
/usr/local/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:186: in exec_module
    exec(co, module.__dict__)
app/tests/conftest.py:14: in <module>
    from app.core.config import settings
E   ModuleNotFoundError: No module named 'app.core'

When I try to append an extra app. to the imports (e.g., from app.app.core.config import settings, the error goes away, but then my regular backend service crashes (ModuleNotFoundError app.app). Clearly it is some difference between how pytest and running the service regularly handle imports.

My file structure is the same as the template project: the main.py for FastAPI lives at backend/app/app, my pyproject.toml lives at backend/app.

I am running pytest 7.1.3, python 3.10, and Mac OS 14.1.

frontend build error

Hi! I'm having issues running the frontend service with the following error during docker-compose up -d:

frontend_1      | yarn run v1.22.19
frontend_1      | $ nuxt start
frontend_1      | /bin/sh: 1: nuxt: not found
frontend_1      | error Command failed with exit code 127.
frontend_1      | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any idea about what's happening here?

Internal server error on user profile creation instead of Validation Error

I tried to call create_user_profile view but it failed with Internal Server Error on schema check

user_in = schemas.UserCreate(password=password, email=email, full_name=full_name)
Traceback (most recent call last):
   File "/app/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
     result = await app(  # type: ignore[func-returns-value]
   File "/app/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
     return await self.app(scope, receive, send)
   File "/app/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 270, in __call__
     await super().__call__(scope, receive, send)
   File "/app/.venv/lib/python3.10/site-packages/starlette/applications.py", line 124, in __call__
     await self.middleware_stack(scope, receive, send)
   File "/app/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
     raise exc
   File "/app/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
     await self.app(scope, receive, _send)
   File "/app/.venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 92, in __call__
     await self.simple_response(scope, receive, send, request_headers=headers)
   File "/app/.venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 147, in simple_response
     await self.app(scope, receive, send)
   File "/app/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
     raise exc
   File "/app/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
     await self.app(scope, receive, sender)
   File "/app/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
     raise e
   File "/app/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
     await self.app(scope, receive, send)
   File "/app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 706, in __call__
     await route.handle(scope, receive, send)
   File "/app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
     await self.app(scope, receive, send)
   File "/app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
     response = await func(request)
   File "/app/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 235, in app
     raw_response = await run_endpoint_function(
   File "/app/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
     return await run_in_threadpool(dependant.call, **values)
   File "/app/.venv/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
     return await anyio.to_thread.run_sync(func, *args)
   File "/app/.venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
     return await get_asynclib().run_sync_in_worker_thread(
   File "/app/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
     return await future
   File "/app/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
     result = context.run(func, *args)
   File "/app/app/api/api_v1/endpoints/users.py", line 37, in create_user_profile
     user_in = schemas.UserCreate(password=password, email=email, full_name=full_name)
   File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
 pydantic.error_wrappers.ValidationError: 1 validation error for UserCreate
 password
   ensure this value has at least 8 characters (type=value_error.any_str.min_length; limit_value=8)

Postgres 14 exits due to version incompatibility

I am getting the following error message on Docker version 20.10.21, build baeda1f

Log:

2023-01-17 16:09:23 
2023-01-17 16:09:23 PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-01-17 16:09:23 
2023-01-17 16:16:22 
2023-01-17 16:16:22 PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-01-17 16:16:22 
2023-01-17 16:16:26 
2023-01-17 16:16:26 PostgreSQL Database directory appears to contain a database; Skipping initialization
2023-01-17 16:16:26 
2023-01-17 16:09:23 2023-01-17 21:09:23.872 UTC [1] FATAL:  database files are incompatible with server
2023-01-17 16:09:23 2023-01-17 21:09:23.872 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 14.6 (Debian 14.6-1.pgdg110+1).
2023-01-17 16:16:22 2023-01-17 21:16:22.992 UTC [1] FATAL:  database files are incompatible with server
2023-01-17 16:16:22 2023-01-17 21:16:22.992 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 14.6 (Debian 14.6-1.pgdg110+1).
2023-01-17 16:16:26 2023-01-17 21:16:26.718 UTC [1] FATAL:  database files are incompatible with server
2023-01-17 16:16:26 2023-01-17 21:16:26.718 UTC [1] DETAIL:  **The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 14.6 (Debian 14.6-1.pgdg110+1).**

Login issues

Hi,
I have installed using cookiecutter https://github.com/whythawk/full-stack-fastapi-postgresql
everything went fine but I couldnt login into the application. Continuous error is coming like: web-socket.mjs?v=c6c77b63:58 WebSocket connection to 'ws://localhost:4000/ws' failed: even without giving logindetails. even after entering login credentials still the application throwing errors in console continuously.
image
oauth is successful but page is not loading.
image
I guess something is wrong with websocket and cors origins. Anybody have any idea please suggest.

Websocket Support

Hi, Im using this template for my project but I can't get websockets to work at all.

I simply added a quick websocket test to backend/app/main.py:

@app.websocket("/ws/{some_id}")
async def ws_test(websocket: WebSocket):
    await websocket.accept()
    print("Accepted")

When I visit http://localhost, I can see the default blog as expected, however when I connect to ws://localhost/ws/some-id using a websocket client, nothing happens, nothing printed on the server console either. The server just spits out:

"GET /ws/some-id HTTP/1.1" 200 14635 "-" "-" 171 "myapp-com-frontend-http@docker"

Could you help me on how to add websocket support here?

subprocess.CalledProcessError: Command '['sh', '/app/prestart.sh']' returned non-zero exit status 1.

Hi Guys!!

I need help please!

my backend container don't work!

` ensure this value has at least 8 characters (type=value_error.any_str.min_length; limit_value=8)
Traceback (most recent call last):
File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/app/inboard/start.py", line 125, in
run_pre_start_script(logger=logger)
File "/app/inboard/start.py", line 26, in run_pre_start_script
subprocess.run([process, pre_start_path], check=True)
File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['sh', '/app/prestart.sh']' returned non-zero exit status 1.

  • Terminal will be reused by tasks, press any key to close it`

Interest in Pydantic 2.0

With the latest update to FastAPI, there is now support for Pydantic 2.0. Is there interest for an update of this stack to support it?

build.sh throws error: COPY failed: stat app/public: file does not exist

I am (still) playing around with this code base and am trying to run it in production (as is) on a DigitalOcean droplet. I have this successfully running locally, but when I "Build your app images", the command

TAG=prod FRONTEND_ENV=production bash ./scripts/build.sh

returns the following error:

Step 47/55 : COPY --from=build /app/public ./public
ERROR: Service 'frontend' failed to build: COPY failed: stat app/public: file does not exist

This comes from line 50 in frontend/Dockerfile:

COPY --from=build /app/public ./public

Checking the code base, there is no "frontend/public" folder. Any idea what I have done wrong?

Also, there is inconsistency in how to build the images. In the project slug (https://github.com/whythawk/full-stack-fastapi-postgresql/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/README.md) the command is

TAG=prod FRONTEND_ENV=production bash ./scripts/build.sh

whereas the instructions in master (https://github.com/whythawk/full-stack-fastapi-postgresql/blob/master/docs/deployment-guide.md#docker-swarm-mode) is

DOMAIN=example.com TRAEFIK_TAG=example.com STACK_NAME=example-com TAG=prod bash -x scripts/deploy.sh

which one is correct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.