Containerfile and compose
This commit is contained in:
@ -9,4 +9,4 @@ chrono = { version = "0.4", features = ["serde"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0" }
|
||||
icalendar = { version = "0.17", features = ["serde", "serde_json"] }
|
||||
tokio = { version = "1.47.1", features = ["macros", "rt-multi-thread"] }
|
||||
tokio = { version = "1.47.1", features = ["macros", "rt-multi-thread"] }
|
||||
|
27
Containerfile
Normal file
27
Containerfile
Normal file
@ -0,0 +1,27 @@
|
||||
# Use a Rust base image with Cargo installed
|
||||
FROM rust:1.90 AS builder
|
||||
LABEL authors="Martin Berg Alstad"
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Now copy the source code
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY ./src ./src
|
||||
|
||||
# Build your application
|
||||
RUN cargo build --release
|
||||
|
||||
# Start a new stage to create a smaller image without unnecessary build dependencies
|
||||
FROM debian:trixie-slim
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy the built binary from the previous stage
|
||||
COPY --from=builder /usr/src/app/target/release/recurring-event-api ./
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
# Command to run the application
|
||||
ENTRYPOINT ["./recurring-event-api"]
|
10
compose.yaml
Normal file
10
compose.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
services:
|
||||
recurring-event-api:
|
||||
restart: unless-stopped
|
||||
container_name: recurring-event-api
|
||||
image: recurring-event-api
|
||||
build:
|
||||
dockerfile: Containerfile
|
||||
context: .
|
||||
ports:
|
||||
- "8095:8000"
|
@ -151,10 +151,13 @@ fn get_dates(
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
const PORT: &'static str = "8000";
|
||||
let app = Router::new()
|
||||
.route("/", get(get_calendar))
|
||||
.route("/ics", get(get_ics));
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:8000").await.unwrap();
|
||||
println!("Starting Application on port {PORT}");
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{PORT}")).await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
|
Reference in New Issue
Block a user