Domains do not work with a dockerized rust project.

I have tried several ways to make it work, both by just exposing the ports - 3000 and by using expose:.
services:
search_engine:
container_name: rust-search-engine-app # Explicit container name
image: rust-search-engine:latest # Optional: Tag the image being built
build:
context: . # Use the current directory as the build context
dockerfile: Dockerfile # Specify the Dockerfile name
ports:
- "${PORT}:3000"
environment:
- RUST_LOG=info,api=debug
- PORT=${PORT}
restart: unless-stopped # Restart policy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:${PORT}/health || exit 1"]
interval: 15s # Check every 15 seconds
timeout: 5s # Wait max 5 seconds for response
retries: 3 # Try 3 times before marking as unhealthy
start_period: 20s # Grace period after container starts
services:
search_engine:
container_name: rust-search-engine-app # Explicit container name
image: rust-search-engine:latest # Optional: Tag the image being built
build:
context: . # Use the current directory as the build context
dockerfile: Dockerfile # Specify the Dockerfile name
ports:
- "${PORT}:3000"
environment:
- RUST_LOG=info,api=debug
- PORT=${PORT}
restart: unless-stopped # Restart policy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:${PORT}/health || exit 1"]
interval: 15s # Check every 15 seconds
timeout: 5s # Wait max 5 seconds for response
retries: 3 # Try 3 times before marking as unhealthy
start_period: 20s # Grace period after container starts
No description
17 Replies
Henrik
Henrik5d ago
Remove container_name, you may get the wrong logs Don't bind port to host. That shouldn't have worked if you installed Dokploy the default way. It uses that port
Freilyn Bernabe
Freilyn BernabeOP5d ago
@Henrik Thanks for responding, Docker Compose is now like this but it still doesn't work for me.
services:
search_engine:
image: rust-search-engine:latest # Optional: Tag the image being built
build:
context: . # Use the current directory as the build context
dockerfile: Dockerfile # Specify the Dockerfile name
environment:
- RUST_LOG=info,api=debug
restart: unless-stopped # Restart policy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/health || exit 1"]
interval: 15s # Check every 15 seconds
timeout: 5s # Wait max 5 seconds for response
retries: 3 # Try 3 times before marking as unhealthy
start_period: 20s # Grace period after container starts
services:
search_engine:
image: rust-search-engine:latest # Optional: Tag the image being built
build:
context: . # Use the current directory as the build context
dockerfile: Dockerfile # Specify the Dockerfile name
environment:
- RUST_LOG=info,api=debug
restart: unless-stopped # Restart policy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/health || exit 1"]
interval: 15s # Check every 15 seconds
timeout: 5s # Wait max 5 seconds for response
retries: 3 # Try 3 times before marking as unhealthy
start_period: 20s # Grace period after container starts
Henrik
Henrik5d ago
Is it healthy?
Freilyn Bernabe
Freilyn BernabeOP5d ago
Yes
No description
Henrik
Henrik5d ago
You've added the route in the domain tab? If you click on the name there, it isnt a bunch of containers that have died?
Freilyn Bernabe
Freilyn BernabeOP5d ago
Yes I think everything is fine but the domain doesn't work.
Freilyn Bernabe
Freilyn BernabeOP5d ago
GitHub
GitHub - bernabedev/rust_search_engine: A high-performance, work-in...
A high-performance, work-in-progress search engine built from scratch in Rust - bernabedev/rust_search_engine
Henrik
Henrik5d ago
I'll try
Henrik
Henrik5d ago
It's not a healthy app
No description
Freilyn Bernabe
Freilyn BernabeOP5d ago
Thats true, Apparently I don't get along very well with Docker.
Henrik
Henrik5d ago
No worries. That was an easy fix I'll just validate it on a server first And maybe fix up a bit on the Dockerfile
Henrik
Henrik5d ago
Yup. Worked like a charm
No description
Freilyn Bernabe
Freilyn BernabeOP5d ago
@Henrik Thanks. I really wouldn't have found what was going on without your help. I see I needed to install curl on Debian. To verify the health check
Henrik
Henrik5d ago
Yup. It was just that
Freilyn Bernabe
Freilyn BernabeOP5d ago
You are literally the best - thank you! @Henrik
Henrik
Henrik4d ago
I tried some of my old tricks with docker caching, but it din't work so well on projects that is this splitted up into several crates. Wasn't any speedup gain there Your Dockerfile can be improved quite a bit. I noticed it has to recompile all the dependencies for any changes made to your source code. This one will cache your built dependencies a lot better.

Did you find this page helpful?