Not sure where to connect to the docker images after deploying to server
jymchng opened this issue ยท 8 comments
Hi, using backend/docker-compose.yml
I have deployed the docker containers to my private server. However, I am unable to curl
or connect to it using my browser. Can you advise how I should do that?
Thank you.
Hello @jymchng you make sure that you set your custom domain in environment variables. or use you public IP
EXT_ENDPOINT1=mycustomwebsite.com so that I can get access with both mycustomwebsite.com or fastapi.mycustomwebsite.com
EXT_ENDPOINT1=172.10.10.10 so that I can get access to 172.10.10.10. Subdomains do not work with IP addresses, so I recommend you get a custom domain on servers.
@jonra1993 Thank you for your reply. Just another follow up question, how can I get from HTTP to HTTPS? Thank you.
Hello @jymchng this can be helpful. The project uses Caddy as reverse proxy which automatically creates SSL certificates
#59 (comment)
Another option could be using cloudflare and providing a certificate using its free https proxy
Hello @jonra1993, thank you for your helpful reply!
I have another question.
Let's say I have a Project
table, shown below:
from sqlmodel import SQLModel
class Project(SQLModel, table=True):
featured: bool = False
If I have an API that sets the Project.featured = True
but I want it to be set to False
3 days later. What suggestions do you have to achieve this?
Thank you.
Hello @jymchng I think that is a crontab task you can use celery beats and create a celery task after someone changes featured to True. Something like this
https://github.com/jonra1993/fastapi-alembic-sqlmodel-async/blob/main/backend/app/app/api/v1/endpoints/periodic_tasks.py
on crontab you calculate 3 days after right now
periodic_task.crontab = CrontabSchedule(
hour=22, minute=14, day_of_month=29, month_of_year=3, timezone="UTC"
)
Hi @jonra1993, thank you for this awesome template.
After I tried to deploy with your Caddyfile, attempting to enable HTTPS, this is the error I got:
caddy_reverse_proxy | {"level":"error","ts":1680712202.3448455,"logger":"http.acme_client","msg":"validating authorization","identifier":"static.mycustomdomain.com","problem":{"type":"urn:ietf:params:acme:error:dns","title":"","detail":"DNS problem: NXDOMAIN looking up A for static.mycustomdomain.com - check that a DNS record exists for this domain; DNS problem: NXDOMAIN looking up AAAA for static.mycustomdomain.com - check that a DNS record
exists for this domain","instance":"","subproblems":[]},"order":"https://acme-staging-v02.api.letsencrypt.org/acme/order/96894614/8124165414","attempt":2,"max_attempts":3}
I am running docker-compose-dev.yml for testing on my local machine. What should I do?
Hello @jymchng you can not use SSL perfectly locally because you will require a public static IP also your local router should allow public connections and a DNS server which points A record to your PC public IP.
The error says that mycustomdomain.com is not in your local namespace and Cady can not generate a SSL certificate.
For development, I recommend you use HTTP. If you want to use SSL which is for production better use a remote server and connect a custom domain using a DNS server like Cloudflare which points the custom domain to your remote server. In such a situation, it is going to work perfectly. something like this
I hope it can help.
Thank you for your response @jonra1993, I wish I can give you more stars than what you have now!