Compare commits

...

7 commits

6 changed files with 92 additions and 7 deletions

View file

@ -16,6 +16,7 @@ async fn main() -> anyhow::Result<std::convert::Infallible> {
log::trace!("Creating Axum router..."); log::trace!("Creating Axum router...");
let app = axum::Router::new() let app = axum::Router::new()
.route("/.healthcheck", axum::routing::get(route::healthcheck_handler))
.layer(Extension(Arc::new(mj))); .layer(Extension(Arc::new(mj)));
log::trace!("Axum router created successfully!"); log::trace!("Axum router created successfully!");

View file

@ -0,0 +1,14 @@
use axum::http::StatusCode;
use acrate_database::connect::connect_async;
pub async fn healthcheck_handler() -> Result<StatusCode, StatusCode> {
log::debug!("Handling an healthcheck request!");
log::trace!("Making sure the database is up...");
let _conn = connect_async()
.await
.map_err(|_| StatusCode::BAD_GATEWAY)?;
log::trace!("Healthcheck successful! Everything's fine!");
Ok(StatusCode::NO_CONTENT)
}

View file

@ -30,3 +30,12 @@ COPY --from=rdserver_build /usr/src/acrate/target/release/acrate_rdserver /usr/l
ENTRYPOINT ["acrate_rdserver"] ENTRYPOINT ["acrate_rdserver"]
HEALTHCHECK CMD ["curl", "http://127.0.0.1/.healthcheck"] HEALTHCHECK CMD ["curl", "http://127.0.0.1/.healthcheck"]
ENV RUST_LOG="warn,acrate_rdserver=info" ENV RUST_LOG="warn,acrate_rdserver=info"
FROM base_builder AS apub_inbox_build
RUN cargo build --release --package=acrate_apub_inbox --bin=acrate_apub_inbox
FROM base_runner AS apub_inbox
COPY --from=apub_inbox_build /usr/src/acrate/target/release/acrate_apub_inbox /usr/local/bin/acrate_apub_inbox
ENTRYPOINT ["acrate_apub_inbox"]
HEALTHCHECK CMD ["curl", "http://127.0.0.1/.healthcheck"]
ENV RUST_LOG="warn,acrate_apub_inbox=info"

View file

@ -51,12 +51,6 @@ services:
- type: "volume" - type: "volume"
source: "postgres_data" source: "postgres_data"
target: "/var/lib/postgresql/data" target: "/var/lib/postgresql/data"
ports:
# FIXME: for development purposes only
- protocol: "tcp"
host_ip: "127.0.0.1"
target: 5432
published: 5432
expose: expose:
- 5432 - 5432
healthcheck: healthcheck:
@ -84,7 +78,26 @@ services:
target: "rdserver" target: "rdserver"
restart: "unless-stopped" restart: "unless-stopped"
environment: environment:
ACRATE_WEBFINGER_BIND_ADDRESS: "0.0.0.0:80" ACRATE_RDSERVER_BIND_ADDRESS: "0.0.0.0:80"
ACRATE_DATABASE_URL: *database_url
expose:
- 80
depends_on:
database:
condition: "service_healthy"
migrate:
condition: "service_completed_successfully"
# ActivityPub inbox server
apub_inbox:
build:
dockerfile: "./Dockerfile"
additional_contexts:
- "source=.."
target: "apub_inbox"
restart: "unless-stopped"
environment:
ACRATE_APUB_INBOX_BIND_ADDRESS: "0.0.0.0:80"
ACRATE_DATABASE_URL: *database_url ACRATE_DATABASE_URL: *database_url
expose: expose:
- 80 - 80

View file

@ -13,4 +13,22 @@
health_uri "/.healthcheck" health_uri "/.healthcheck"
health_status "204" health_status "204"
} }
@inbox {
path "/inbox"
}
reverse_proxy @inbox {
to "http://inbox"
health_uri "/.healthcheck"
health_status "204"
}
}
{
admin {
origins "127.0.0.1"
enforce_origin
}
} }

View file

@ -0,0 +1,30 @@
# Docker Compose file to be merged with compose.yml to expose service ports to localhost for debugging purposes
services:
ingress:
ports:
- protocol: "tcp"
host_ip: "127.0.0.1"
target: 30000
published: 2019
database:
ports:
- protocol: "tcp"
host_ip: "127.0.0.1"
target: 30001
published: 5432
rdserver:
ports:
- protocol: "tcp"
host_ip: "127.0.0.1"
target: 30002
published: 80
apub_inbox:
ports:
- protocol: "tcp"
host_ip: "127.0.0.1"
target: 30003
published: 80