From 0bdf75446d9967cef276f9018e3af3230d4d2c16 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sun, 28 Jul 2024 16:12:06 +0200 Subject: [PATCH] update --- .forgejo/workflows/deploy.yml | 35 +++++++++++++++++++++++++++++++++++ Dockerfile | 17 +++++++++++++++++ src/library/user.rs | 2 +- src/main.rs | 6 +++++- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .forgejo/workflows/deploy.yml create mode 100644 Dockerfile diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml new file mode 100644 index 0000000..fa56119 --- /dev/null +++ b/.forgejo/workflows/deploy.yml @@ -0,0 +1,35 @@ +name: deploy + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: host + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + registry: git.hydrar.de + username: ${{ secrets.registry_user }} + password: ${{ secrets.registry_password }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: git.hydrar.de/synthwrld/synthwave:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a1d7f66 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM rust:buster as builder + +COPY . /app +WORKDIR /app + +RUN cargo build --release + +FROM debian:buster + +RUN apt update && apt upgrade -y +RUN apt install -y gnupg ca-certificates openssl + +COPY --from=builder /app/target/release/synthwave /synthwave + +WORKDIR / + +CMD ["/synthwave"] \ No newline at end of file diff --git a/src/library/user.rs b/src/library/user.rs index 00eca6b..910a8a1 100644 --- a/src/library/user.rs +++ b/src/library/user.rs @@ -53,7 +53,7 @@ impl User { role, }; - u.insert().await.unwrap(); + u.insert().await.ok()?; Some(u) } diff --git a/src/main.rs b/src/main.rs index a86609e..67754f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod route; use rocket::routes; use rocket::{http::Method, launch}; +use library::user::{User, UserRole}; #[launch] async fn rocket() -> _ { @@ -25,6 +26,8 @@ async fn rocket() -> _ { lib.rescan().await; + User::create("admin", "admin", UserRole::Admin).await; + rocket::build() .mount( "/", @@ -35,7 +38,8 @@ async fn rocket() -> _ { route::album::album_route, route::track::track_route, route::track::track_audio_route, - route::album::album_cover_route + route::album::album_cover_route, + route::user::login_route ], ) .manage(lib)