Compare commits

...

7 Commits

Author SHA1 Message Date
41becd8b7a Use reqwest_api version of libretunes
All checks were successful
Push Workflows / docs (push) Successful in 51s
Push Workflows / build (push) Successful in 1m4s
Push Workflows / test (push) Successful in 1m3s
Push Workflows / docker-build (push) Successful in 2m50s
2025-05-06 04:43:53 +00:00
3cd9daad28 Cargo update 2025-05-06 04:42:46 +00:00
6fe4cb5d9b Change build job command from cargo-leptos to cargo
Some checks failed
Push Workflows / build (push) Failing after 38s
Push Workflows / docs (push) Failing after 35s
Push Workflows / test (push) Failing after 38s
Push Workflows / docker-build (push) Successful in 2m49s
2024-10-04 17:08:01 -04:00
e45c440a37 Create push workflows
Some checks failed
Push Workflows / build (push) Failing after 38s
Push Workflows / docs (push) Successful in 2m5s
Push Workflows / docker-build (push) Failing after 28s
Push Workflows / test (push) Successful in 2m39s
2024-10-04 17:04:03 -04:00
4f2a573b9e Add gitignore 2024-10-04 16:57:36 -04:00
6363585b43 Create Dockerfile 2024-10-04 16:56:51 -04:00
8d45f987d5 Create main.rs file 2024-10-04 16:56:29 -04:00
7 changed files with 1263 additions and 1737 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
# Ignore everything
*
# Except:
!/src
!/Cargo.lock
!/Cargo.toml

View File

@ -0,0 +1,67 @@
name: Push Workflows
on: push
jobs:
build:
runs-on: libretunes-cicd
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build project
env:
RUSTFLAGS: "-D warnings"
run: cargo build
docker-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea container registry
uses: docker/login-action@v3
with:
registry: ${{ env.registry }}
username: ${{ env.actions_user }}
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
- name: Get Image Name
id: get-image-name
run: |
echo "IMAGE_NAME=$(echo ${{ env.registry }}/${{ gitea.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: "${{ steps.get-image-name.outputs.IMAGE_NAME }}:${{ gitea.sha }}"
cache-from: type=registry,ref=${{ steps.get-image-name.outputs.IMAGE_NAME }}:${{ gitea.sha }}
cache-to: type=inline
- name: Build and push Docker image with "latest" tag
uses: docker/build-push-action@v5
if: gitea.ref == 'refs/heads/main'
with:
push: true
tags: "${{ steps.get-image-name.outputs.IMAGE_NAME }}:latest"
cache-from: type=registry,ref=${{ steps.get-image-name.outputs.IMAGE_NAME }}:latest
cache-to: type=inline
test:
runs-on: libretunes-cicd
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Test project
run: cargo test --all-targets --all-features
docs:
runs-on: libretunes-cicd
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate docs
run: cargo doc --no-deps
- name: Upload docs
uses: actions/upload-artifact@v3
with:
name: docs
path: target/doc

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Generated by Cargo
# will have compiled files and executables
/target/

2846
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,5 +5,5 @@ edition = "2021"
[dependencies] [dependencies]
dotenvy = "0.15.7" dotenvy = "0.15.7"
libretunes = { git = "https://git.libretunes.xyz/LibreTunes/LibreTunes.git", default-features = false, features = ["ssr"] } libretunes = { git = "https://git.libretunes.xyz/LibreTunes/LibreTunes.git", default-features = false, features = ["reqwest_api"] }
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }

69
Dockerfile Normal file
View File

@ -0,0 +1,69 @@
FROM rust:slim as builder
WORKDIR /app
RUN rustup default nightly
# Install a few dependencies
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
pkg-config \
clang \
build-essential \
libssl-dev \
libpq-dev \
wget; \
rm -rf /var/lib/apt/lists/*
# Install ImageMagick
RUN cd / && \
wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.1-38.tar.gz && \
tar xf 7.1.1-38.tar.gz && \
rm 7.1.1-38.tar.gz && \
cd ImageMagick-7.1.1-38 && \
./configure && \
make install -j $(nproc) && \
cd .. && \
rm -rf ImageMagick-7.1.1-38
# Copy project dependency manifests
COPY Cargo.toml Cargo.lock /app/
# Create dummy file to force cargo to build the dependencies
RUN mkdir /app/src && echo "fn main() {}" > /app/src/main.rs
# Prebuild dependencies
RUN cargo build --release
RUN rm -rf /app/src
COPY src /app/src
# Touch main to force rebuild
RUN touch /app/src/main.rs
# Actually build the binary
RUN cargo build --release
# Use ldd to list all dependencies of /app/target/release/ingest, then copy them to /app/libs
# Setting LD_LIBRARY_PATH is necessary to find the ImageMagick libraries
RUN mkdir /app/libs && LD_LIBRARY_PATH=/usr/local/lib ldd /app/target/release/ingest | grep "=> /" | \
awk '{print $3}' | xargs -I '{}' cp '{}' /app/libs
# Build the final image
FROM scratch
LABEL license="MIT"
LABEL description="LibreTunes, an open-source browser audio player and \
library manager built for collaborative listening."
# Copy the binary and the compressed assets to the "site root"
COPY --from=builder /app/target/release/ingest /ingest
# Copy libraries to /lib64
COPY --from=builder /app/libs /lib64
COPY --from=builder /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
ENV LD_LIBRARY_PATH=/lib64
ENTRYPOINT [ "/ingest" ]

6
src/main.rs Normal file
View File

@ -0,0 +1,6 @@
use dotenvy::dotenv;
#[tokio::main]
async fn main() {
dotenv().ok();
}