I'M SORRY if this is a noob question but I'm having a hard time resolving a problem and I hope the community can help me out. I have a rust application that compiles into a binary and a library.
path = "src/lib.rs"
[[bin]]
name = "psp"
path = "src/main.rs"
the application has a grpc service that I have built. I will call it a price-server.. its purpose is to feed ny application prices which my app then uses to make payment request.. my app works fine outside of docker, but when i dockerized my app. it doesn't work and i get service not available for the grpc price server. i have done a lot of research to figure out how i can work my docker-compose.yml file to enable the price server works inside a docker environment. .
The examples i have seen created a separate service for their grpc service(client and server). I'm a bit reluctant to follow this approach, as my grpc is not a separate service on its own, but part of my overall application. I'm really short of options on what to do next. . below is what my docker-compos.yml file looks like, with all important things stripped out.
other services
>>>>
integration-tests:
build:
context: .
dockerfile: Dockerfile
tags:
- 'image:app.psp'
depends_on:
- integration-deps
command: ["/wait-for-it.sh", "payments.db:5432", "--", "make", "test-in-ci"]
env_file:
- .env.test
working_dir: /repo
volumes:
- ./:/repo
- cargo-cache:/usr/local/cargo
- ./wait-for-it.sh:/wait-for-it.sh
service_app: # This service is for running our application independently
image: paysystem # This assumes our application's image is tagged as paysystem when we build it
ports:
- "3273:3273" # Grpc port of our price client
- "3000:3000" # We Map port 3000 inside the container to port 3000 on the host for external access
depends_on:
- payments.db
- redis
- bitcoind
- fulcrum
environment:
- REDIS_HOST=redis
env_file:
- .env
command: ["/wait-for-it.sh", "payments.db:5432", "--", "./psp"]
volumes:
- ./wait-for-it.sh:/wait-for-it.sh # We mount the wait-for-it.sh script into the container
volumes:
cargo-cache:
Hello Jendrikw thanks for taking an interest, when I run the application container, the application works fine, but the grpc service doesn't work. I get service not available. outside of docker, everything works perfectly fine. the grpc service(server, client) is part of my overall application rather than a separate services on their own. so I cant create a separate service for them in my docker-compose.yml file as i have seen most blogs articles are doing.. i want to be able to have access to the grpc service as i do outside docker.
Is the output of the grpc server different when you run it inside docker? Have a look at docker ps while it is running. Are the ports correct? Try exec into the container and look at the ports used with ss or netstat.
Yes sir, I already did all this. the only thing it tells me is that service is not available. but my application logs work fine with no errors. the issue comes when I want to generate a payment, and the application needs the grpc service to provide the price data, and since it's not available I get this error below { "message": "Price server error: TonicStatus error: Message: PriceCacheError: No price in cache, Code: \"The service is currently unavailable\"" }.
If you can reach port 3273 and the service on the port, then next step would be to check if the service can connect where it needs to connect to provide the price item.
Can you connect from the docker container to the, let's say, database, and you can resolve it? From your previous message suggests it would be a application error.
This looks like it's ran as part of a docker compose setup, is the same docker compose setup on the local and remote host ?
There's few unknowns to give a precise answer.
On Postman when I run my full application without docker I can access it, I imported my proto-files into Postman. everything checked out. but when I run my application as a dockerized app, I can't access this, I get the service is not available. so i don't think its an application issue.
This looks like it's ran as part of a docker compose setup,
There's few unknowns to give a precise answer.
Yes its running as a docker-compose.yml file setup. that is how i have set up my application. my full app works with like five services, (redis, db, bitcoind, and, fulcrum). I orchestrated this using docker-compose.and added my app also as a service. as you can from the dockerfile with the main question.
is the same docker-compose setup on the local and remote host ?
Yes, I'm trying to run everything in the same machine.