dockerfile & heroku added

This commit is contained in:
Víctor Martínez 2021-03-21 20:25:28 +01:00
parent 4e0ca5821e
commit 943c0f3391
3 changed files with 23 additions and 1 deletions

15
Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM rust:1.50.0 as build
WORKDIR /app
COPY . .
RUN cargo build --release
RUN mkdir -p /build-out
RUN cp target/release/actix-messaging /build-out/
# Ubuntu 18.04
FROM ubuntu:18.04 as production
RUN apt-get update && apt-get -y install ca-certificates libssl-dev && rm -rf /var/lib/apt/lists/*
COPY --from=build /build-out/* /
CMD [ "./actix-messaging" ]

3
heroku.yml Normal file
View file

@ -0,0 +1,3 @@
build:
docker:
app: Dockerfile

View file

@ -11,13 +11,17 @@ use routes::connect;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let port = std::env::var("PORT").expect("PORT env variable not found");
let addr = format!("127.0.0.1:{}", port);
let chat = ChatServer::new().start();
HttpServer::new(move || {
App::new()
.data(AppState { chat: chat.clone() })
.service(connect)
})
.bind("127.0.0.1:8080")?
.bind(&addr)?
.run()
.await
}