Require DATABASE_URL to be set
This commit is contained in:
parent
b2095e98fb
commit
757e670dbb
3 changed files with 10 additions and 2 deletions
|
@ -28,6 +28,8 @@ RUN addgroup -S user && adduser -S user -G user
|
|||
WORKDIR /runner
|
||||
# Copy the server binary and the public directory, note the debug binary
|
||||
COPY --from=builder /build/target/x86_64-unknown-linux-musl/debug/server /runner/server
|
||||
RUN mkdir /runner/public
|
||||
RUN echo "Debug build!" > /runner/public/index.html
|
||||
|
||||
# Make sure the user can access the files
|
||||
RUN chown -R user:user /runner
|
||||
|
|
4
justfile
4
justfile
|
@ -22,7 +22,7 @@ build-container-server-debug:
|
|||
# Builds a debug container and runs it
|
||||
[private]
|
||||
start-debug: build-container-server-debug remove-podman-containers
|
||||
{{runtime}} run -d -p 8080:8080 --name frostbyte-debug fb-server-debug
|
||||
{{runtime}} run -d -e DATABASE_URL=sqlite:debug.db -p 8080:8080 --name frostbyte-debug fb-server-debug
|
||||
@echo "Debug server started."
|
||||
|
||||
# Builds a release container
|
||||
|
@ -32,6 +32,7 @@ build-container-release:
|
|||
|
||||
# Builds a release container and runs it
|
||||
start-release: build-container-release remove-podman-containers
|
||||
{{runtime}} network create fb_network --ignore
|
||||
{{runtime}} run -d --network fb_network -e DATABASE_URL=sqlite:release.db -p 8080:8080 --name frostbyte fb-server
|
||||
|
||||
init-sqlx:
|
||||
|
@ -43,6 +44,7 @@ init-sqlx:
|
|||
# Removes and stops any containers related to the project
|
||||
[private]
|
||||
remove-podman-containers:
|
||||
{{runtime}} network rm -f fb_network
|
||||
{{runtime}} container rm -f frostbyte
|
||||
{{runtime}} container rm -f frostbyte-debug
|
||||
|
||||
|
|
|
@ -31,7 +31,11 @@ impl ServerState {
|
|||
pub async fn new() -> Self {
|
||||
// This is almost certainly bad practice for more reasons than I can count
|
||||
dotenvy::dotenv().ok();
|
||||
let db_url = dotenvy::var("DATABASE_URL").unwrap_or(":memory:".to_string());
|
||||
let db_url = dotenvy::var("DATABASE_URL").unwrap_or_else(|_| {
|
||||
error!("DATABASE_URL not set in environment!");
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
||||
info!("Using db_url: {}", &db_url);
|
||||
|
||||
if !sqlx::Sqlite::database_exists(&db_url).await.unwrap() {
|
||||
|
|
Loading…
Reference in a new issue