diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d698750 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM rust:latest AS builder +WORKDIR /usr/src/hal +COPY . . +RUN cargo install --path . + +FROM debian:bookworm-slim +RUN apt-get update && apt-get install -y libpq5 libssl3 && rm -rf /var/lib/apt/lists/* +RUN mkdir -pv /srv/hal +COPY --from=builder /usr/local/cargo/bin/hal /srv/hal +RUN chmod a+x /srv/hal/hal +COPY --from=builder /usr/src/hal/config /srv/hal/config +COPY --from=builder /usr/src/hal/txt /srv/hal/txt +RUN find /srv/hal/ +WORKDIR /srv/hal +CMD ["./hal", "-e", "development"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..d9c6f16 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,17 @@ +services: + hal: + depends_on: + psql: + condition: service_started + restart: true + build: . + environment: + - DISCORD_TOKEN=${DISCORD_TOKEN} + - RUST_LOG=warn + psql: + image: postgres + restart: always + # set shared memory limit when using docker compose + shm_size: 128mb + environment: + POSTGRES_PASSWORD: "7ZhUVzr7sxcPEEDMdxfEryW4NTZX5C2ufzZd3r2s25xULgH7FWXJVts" diff --git a/config/development.hal.json b/config/development.hal.json index 8910657..b8b0d7c 100644 --- a/config/development.hal.json +++ b/config/development.hal.json @@ -2,10 +2,10 @@ "prefix": "!", "nickname": "Hal 9000", "database": { - "host": "127.0.0.1", - "user": "badgey_development", + "host": "psql", + "user": "postgres", "pass": "7ZhUVzr7sxcPEEDMdxfEryW4NTZX5C2ufzZd3r2s25xULgH7FWXJVts", - "database_name": "hal_development", + "database_name": "postgres", "port": 5432 }, "channels": { diff --git a/src/hal/mod.rs b/src/hal/mod.rs index 461c540..3176f40 100644 --- a/src/hal/mod.rs +++ b/src/hal/mod.rs @@ -16,6 +16,8 @@ pub async fn run(arguments: ArgMatches) { let git_info: String = built_info::GIT_VERSION.unwrap_or("unknown").to_string(); let version_string = format!("Hal 9000 Bot version {ver} built at {time} from revision {rev}", ver=built_info::PKG_VERSION, time=built_info::BUILT_TIME_UTC, rev=git_info).to_string(); + warn!("HAL Client initialising..."); + let client = match manifold::prepare_client::(arguments, GatewayIntents::all(), commands::collect_commands(), version_string, MIGRATIONS).await { Ok(c) => c, Err(e) => { @@ -24,5 +26,7 @@ pub async fn run(arguments: ArgMatches) { } }; + warn!("HAL Client connecting..."); + let _ = client.build().await.unwrap().start().await; } \ No newline at end of file