Load environment variables from .env files

This allows to properly set the OAuth 2.0 Issuer base in the Codespace
This commit is contained in:
Quentin Gliech
2021-08-15 09:21:15 +00:00
committed by GitHub
parent 705b18a9f8
commit 9f4673918d
5 changed files with 8 additions and 0 deletions

1
.devcontainer/.env Normal file
View File

@@ -0,0 +1 @@
MAS_OAUTH2_ISSUER="https://${CODESPACE_NAME}-8080.githubpreview.dev/"

View File

@@ -3,6 +3,8 @@ FROM mcr.microsoft.com/vscode/devcontainers/rust:0-1
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends postgresql-client
COPY .env /.env
# TODO: pre-build custom images, those take too much time
#RUN cargo install sqlx-cli --no-default-features --features postgres
#RUN cargo install cargo-edit

1
Cargo.lock generated
View File

@@ -1255,6 +1255,7 @@ dependencies = [
"cookie",
"crc 2.0.0",
"data-encoding",
"dotenv",
"figment",
"headers",
"hyper",

View File

@@ -39,6 +39,7 @@ serde_with = { version = "1.9.4", features = ["hex", "chrono"] }
clap = "3.0.0-beta.2"
figment = { version = "0.10.6", features = ["env", "yaml", "test"] }
schemars = { version = "0.8.3", features = ["url", "chrono"] }
dotenv = "0.15.0"
# Password hashing
argon2 = { version = "0.2.2", features = ["password-hash"] }

View File

@@ -34,6 +34,9 @@ use self::cli::RootCommand;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Load environment variables from .env files
dotenv::dotenv()?;
// Setup logging & tracing
let fmt_layer = tracing_subscriber::fmt::layer();
let filter_layer = EnvFilter::try_from_default_env().or_else(|_| EnvFilter::try_new("info"))?;