fastapi / full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
MIT License
27.05k stars 4.81k forks source link

"docker-compose up -d" works on ubuntu but does not work on mac. #427

Open santangelx opened 3 years ago

santangelx commented 3 years ago

This is the terminal output:

_docker-compose up -d unexpected character " \ "" in variable name near "\"http://localhost:8080\", \"https://localhost\", \"https://localhost:4200\", \"https://localhost:3000\", \"https://localhost:8080\", \"http://dev.app\", \"https://sta.app\", \"https://mi.app\", \"http://local.dockertoolbox.tiangolo.com\", \"http://localhost.tiangolo.com\"]\nPROJECT_NAME=mifarma\nSECRET_KEY=pswd\nFIRST_SUPERUSER=me\nFIRST_SUPERUSER_PASSWORD=pswd\nSMTP_TLS=False\nSMTP_SSL=True\nSMTP_PORT=465\nSMTP_HOST=smt\nSMTP_USER=noreply@miapp.app\nSMTP_PASSWORD=pswd\nEMAILS_FROM_EMAIL=noreply@miapp.app\n\nSENTRY_DSN=\n\n# Flower\nFLOWER_BASIC_AUTH=admin:pswd\n\n# Postgres\nPOSTGRES_SERVER=db\nPOSTGRES_USER=postgres\nPOSTGRES_PASSWORD=password\nPOSTGRES_DB=app\n\n# PgAdmin\nPGADMIN_LISTEN_PORT=5050\nPGADMIN_DEFAULT_EMAIL=myname@gmail.com\nPGADMIN_DEFAULTPASSWORD=password\n"

The culprit should be in this code (?) even though it works on ubuntu. I've cleared the code of confidential and possibly sensible information but no lines have been erased, only modified.

------------------------------------------CODE------------------------------------------

DOMAIN=localhost
# DOMAIN=local.dockertoolbox.tiangolo.com
# DOMAIN=localhost.tiangolo.com
# DOMAIN=mi.app

STACK_NAME=mi-app

TRAEFIK_PUBLIC_NETWORK=traefik-public
TRAEFIK_TAG=jjj.ap
TRAEFIK_PUBLIC_TAG=traefik-public

DOCKER_IMAGE_BACKEND=b_backend
DOCKER_IMAGE_CELERYWORKER=b_celeryworker
DOCKER_IMAGE_FRONTEND=b_frontend

# Backend
BACKEND_CORS_ORIGINS= ["http://172.19.36.52:8080",  "http://localhost:8080", "https://localhost", "https://localhost:4200", "https://localhost:3000", "https://localhost:8080", "http://mi.app", "https://mi.app", "https://mi.app", "http://local.dockertoolbox.tiangolo.com", "http://localhost.tiangolo.com"]
PROJECT_NAME=Oppenheiser
SECRET_KEY=super_secret_key
FIRST_SUPERUSER=god
FIRST_SUPERUSER_PASSWORD=pswd
SMTP_TLS=False
SMTP_SSL=True
SMTP_PORT=465
SMTP_HOST=priv
SMTP_USER=mail
SMTP_PASSWORD=pswd
EMAILS_FROM_EMAIL=email

SENTRY_DSN=

# Flower
FLOWER_BASIC_AUTH=admin:pswd

# Postgres
POSTGRES_SERVER=db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=pswd
POSTGRES_DB=app

# PgAdmin
PGADMIN_LISTEN_PORT=5050
PGADMIN_DEFAULT_EMAIL=miname@gmail.com
PGADMIN_DEFAULT_PASSWORD=psd
bertyhell commented 3 years ago

maybe double quotes are not allowed in env vars:

BACKEND_CORS_ORIGINS= ["http://172.19.36.52:8080",  "http://localhost:8080", "https:...

maybe this will work?

BACKEND_CORS_ORIGINS= ['http://172.19.36.52:8080',  'http://localhost:8080', 'https:...
alanmckennaAtEncompass commented 3 years ago

What docker/compose versions are you using? Are you using the same for Mac and Ubuntu?

$ docker --version
$ docker-compose --version

FYI I'm here because it seems that docker-compose cannot parse "." in the variable name. Only recently started happening

$ docker --version
Docker version 20.10.8, build 3967b7d
$ docker-compose --version
Docker Compose version v2.0.0
santangelx commented 3 years ago

Thank you both. I ended up testing a few solutions by modifying the BACKEND_CORS_ORIGIN and replaced it with :

BACKEND_CORS_ORIGINS= ["http://localhost:8080","http://172.19.36.52:8080","http://localhost","http://localhost:4200","http://localhost:3000","http://dev.mifarmacia.app","https://stag.mifarmacia.app","https://mifarmacia.app","http://local.dockertoolbox.tiangolo.com","http://localhost.tiangolo.com"]

It seems to be working now. I'll add the docker and docker-compose versions. Note that my friend was using the exact same versions and had no issues.

$ docker -v
Docker version 20.10.8, build 3967b7d
$docker-compose -v
Docker Compose version v2.0.0
santa@MBP-de-Alex mifarma-api % 
buschweaver commented 3 years ago
$ docker -v
Docker version 20.10.8, build 3967b7d
$docker-compose -v
Docker Compose version v2.0.0

The parser doesn't like the space between each array element.

Do this: VARIABLE=["a","b","c"]

Not this: VARIABLE=["a", "b", "c"]

sylvia-shen commented 3 years ago

Hi, I think docker compose V2 has breaking change 👇 https://docs.docker.com/compose/cli-command/

You can:

OR

Hope it helps 😄

arianatlmnts commented 3 years ago

Hi, I think docker compose V2 has breaking change 👇 https://docs.docker.com/compose/cli-command/

You can:

  • use new command
docker compose

OR

  • disable compose v2
docker-compose disable-v2

Hope it helps 😄

This worked for me!

egovedarov commented 3 years ago

For me, dashes are not even allowed in .env files.

shreyaspapi commented 2 years ago

For me, dashes are not even allowed in .env files.

I had the same issue, the comment by @sylvia-shen solved it - https://github.com/tiangolo/full-stack-fastapi-postgresql/issues/427#issuecomment-943205487

jansonjc commented 2 years ago

I had the same issue. Disabling docker compose v2 fixed it (docker-compose disable-v2). What's breaking this?

jansonjc commented 2 years ago

Docker Compose V2 has breaking changes due to which it throws the error while parsing environment file. One solution is to change the environment file by replacing all double quotes with single quotes and by wrapping these environment variables with a double quote (see this example environment file - works with V2 as well as V1.x)