diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..83261d0 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +PORT= +HOST= +DISCORD_ID= +DISCORD_SECRET= +JWT_SECRET= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0b453ad..f0c39e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ **/target **/build **.idea +**.vscode **.iml /node_modules /.pnp .pnp.js pnpm-debug.log* +.env diff --git a/Cargo.lock b/Cargo.lock index be907c3..975c65c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -774,6 +774,12 @@ dependencies = [ "sha2", ] +[[package]] +name = "kankyo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325a11231fa70c1d1b562655db757cefb6022876d62f173831f35bd670ae0c40" + [[package]] name = "lazy_static" version = "1.4.0" @@ -1905,6 +1911,7 @@ dependencies = [ "hmac", "include_dir", "jwt", + "kankyo", "lazy_static", "openssl", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index c080952..9c8ea19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ include_dir = "0.7" lazy_static = "1.4" thiserror = "1.0" either = "1.7" +kankyo = "0.3" # Explicit dependency to compile openssl from openssl-src instead as a workaround for cross-compilation openssl = { version = "0.10", features = ["vendored"] } diff --git a/Dockerfile b/Dockerfile index 6ec6a6d..ff48368 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,7 @@ ARG TARGETARCH RUN rustup target add $(echo $TARGETARCH | sed 's/arm64/aarch64/;s/amd64/x86_64/')-unknown-linux-musl ADD build.rs ./ +ADD .env ./ ADD src ./src COPY --from=REACT_BUILD /app/build ./build diff --git a/README.md b/README.md index 44f35ef..1d0bfcd 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ variable below. Copy the secret and id from the OAuth tab to set as environment ### Environment variables +Can be modified in the [.env](./.env.example) file. + | PORT | TYPE | Default | Description | |------------------|--------|------------------------------------------------------|------------------------------------------------------------------------------| | `PORT` | u16 | 8000 (unmodifiable in debug) | The port to serve the app on | @@ -26,7 +28,10 @@ variable below. Copy the secret and id from the OAuth tab to set as environment $ pnpm install $ pnpm build $ cargo build --release +# Set environment variables manually $ export PORT=;DISCORD_ID=;DISCORD_SECRET=;HOST=;JWT_SECRET=POSTGRES_URL=; +# or using .env +$ mv .env.example .env $ ./target/release/timezone_db ``` diff --git a/src/main.rs b/src/main.rs index a342fbe..45ea6fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,9 @@ mod database; #[launch] fn rocket() -> Rocket { + if let Err(e) = kankyo::init() { + println!("{e}"); + }; let figment = Config::figment() .merge(("port", *constants::PORT)) .merge(("databases.main.url", &*constants::POSTGRES_URL))