diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8bb3045..275fd02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,13 @@ jobs: - name: Setup rust uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Build - run: cargo build --verbose + run: ./build cargo-dev build-image: runs-on: ubuntu-latest diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 9763f68..c753841 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -15,14 +15,19 @@ jobs: - name: Install cross run: cargo install cross --git https://github.com/cross-rs/cross + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Build amd64 binary run: | - cross build --target x86_64-unknown-linux-musl --release + ./build cross x86_x64-unknown-linux-musl mv target/x86_x64-unknown-linux-musl/release/cup ./cup-linux-amd64 - name: Build arm64 binary run: | - cross build --target aarch64-unknown-linux-musl --release + ./build cross aarch64-unknown-linux-musl mv target/aarch64-unknown-linux-musl/release/cup ./cup-linux-arm64 - name: Upload binaries diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8bccfd..40dc1a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,14 +27,19 @@ jobs: - name: Install cross run: cargo install cross --git https://github.com/cross-rs/cross + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Build amd64 binary run: | - cross build --target x86_64-unknown-linux-musl --release + ./build cross x86_x64-unknown-linux-musl mv target/x86_x64-unknown-linux-musl/release/cup ./cup-linux-amd64 - name: Build arm64 binary run: | - cross build --target aarch64-unknown-linux-musl --release + ./build cross aarch64-unknown-linux-musl mv target/aarch64-unknown-linux-musl/release/cup ./cup-linux-arm64 - name: Upload binaries diff --git a/Dockerfile b/Dockerfile index c47cd04..14b6c80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,39 @@ -FROM rust:alpine AS build -WORKDIR / +# Build UI +FROM node:20-alpine3.20 as web +# Copy web folder +COPY ./web ./web +WORKDIR web + +# Install requirements +RUN npm i + +# Build +RUN npm run build + +# Build Cup +FROM rust:1.80.1-alpine3.20 AS build + +# Requirements RUN apk add musl-dev -RUN USER=root cargo new --bin cup +# Copy rust WORKDIR /cup -COPY Cargo.toml Cargo.lock . -RUN cargo build --release -RUN rm -rf src/ +COPY Cargo.toml . +COPY Cargo.lock . +COPY ./src ./src + +# Copy UI from web builder +COPY --from=web /web/dist src/static -COPY src src -# This is a very bad workaround, but cargo only triggers a rebuild this way for some reason -RUN printf "\n" >> src/main.rs +# Build RUN cargo build --release +# Runner FROM scratch + +# Copy binary COPY --from=build /cup/target/release/cup /cup + ENTRYPOINT ["/cup"] \ No newline at end of file diff --git a/build.sh b/build.sh index f4688a3..90baf94 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,32 @@ -#!/bin/sh +#!/bin/bash -rm -rf src/static +# Arguments +METHOD=$1 +TARGET=$2 + +# Frontend cd web/ -bun run build + +# Install requirements +npm i + +# Build +npm run build + +# Copy UI to src folder cp -r dist/ ../src/static -cargo build $@ \ No newline at end of file + +# Check selected method and build + +if [[ $METHOD == 'cargo' ]]; then + echo "Building with cargo..." + cargo build --release +elif [[ $METHOD == 'cargo-dev' ]]; then + echo "Building with cargo using --verbose (dev)..." +elif [[ $METHOD == 'cross' ]]; then + echo "Building with cross for $TARGET..." + cross build --target $TARGET --release +else + echo "Unkown method!" + exit 1 +fi diff --git a/src/static/apple-touch-icon.png b/src/static/apple-touch-icon.png deleted file mode 100644 index ac6ec92..0000000 Binary files a/src/static/apple-touch-icon.png and /dev/null differ diff --git a/src/static/favicon.ico b/src/static/favicon.ico deleted file mode 100644 index 3ee81b1..0000000 Binary files a/src/static/favicon.ico and /dev/null differ diff --git a/src/static/favicon.svg b/src/static/favicon.svg deleted file mode 100644 index 4fe8396..0000000 --- a/src/static/favicon.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - -