I've been trying to see my web app started from my docker-compose file but nothing is appearing. It works when I serve the app locally but not through docker. I'm using rust and actix-web for my backend set for localhost on port 8080 and I'm exposing the ports for docker-compose but it still isn't working.
my docker-compose file:
services:
database:
image: postgres
restart: always
expose:
- 5432
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: zion
PGDATA: /var/lib/postgresql/data/
healthcheck:
test: ["CMD", "pg_isready", "-d", "zion", "-U", "postgres"]
timeout: 25s
interval: 10s
retries: 5
networks:
- postgres-compose-network
test:
build:
context: .
dockerfile: Dockerfile
entrypoint: ./test-entrypoint.sh
depends_on:
database:
condition: service_healthy
networks:
- postgres-compose-network
server:
build:
context: .
dockerfile: Dockerfile
entrypoint: ./run-entrypoint.sh
restart: always
expose:
- 8080
ports:
- 8080:8080
depends_on:
database:
condition: service_healthy
networks:
- postgres-compose-network
networks:
postgres-compose-network:
driver: bridge
backend main.rs
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
log::info!("starting HTTP server at http://localhost:8080");
let secret_key = Key::generate();
let pool = establish_connection();
log::info!("database connection established");
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(pool.clone()))
.wrap(middleware::Logger::default())
.wrap(IdentityMiddleware::default())
.configure(database::routes::user::configure)
.service(
Files::new("/", "../frontend/dist")
.prefer_utf8(true)
.index_file("index.html"),
)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}