diff --git a/.dockerignore b/.dockerignore index 6301bee..430f990 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,7 @@ -* -!target/debug/overload -!target/release/overload \ No newline at end of file +target +.vscode +.github +*.log +.git +.idea +docs \ No newline at end of file diff --git a/.github/workflows/dockerhub-push.yml b/.github/workflows/dockerhub-push.yml index 073842f..c831f43 100644 --- a/.github/workflows/dockerhub-push.yml +++ b/.github/workflows/dockerhub-push.yml @@ -1,7 +1,9 @@ name: Dockerhub on: - push: + workflow_run: + workflows: ["Rust"] + types: [completed] branches: [ main ] release: types: [published] @@ -13,14 +15,10 @@ env: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - - name: install lua - run: sudo apt install -y liblua5.3-dev - - uses: actions/checkout@v2 - - name: Run tests for cluster - run: cargo test --features="cluster" --verbose + - uses: actions/checkout@v4 - name: Get version run: | if [[ ${{ github.event_name }} == 'release' ]]; then @@ -36,27 +34,22 @@ jobs: echo "version=latest" >> "$GITHUB_ENV" echo "suffix=-snapshot" >> "$GITHUB_ENV" fi - - name: Build cluster - run: cargo build --bins --features "cluster" --release - name: Login to Github Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build cluster image - uses: docker/build-push-action@v2.5.0 + uses: docker/build-push-action@v7 with: context: . push: true tags: ghcr.io/${{ github.repository }}:cluster-${{ env.version }}${{ env.suffix }} - - name: Run standalone tests - run: cargo test --verbose - - name: Build standalone - run: cargo build --bins --release - name: Build & push standalone image - uses: docker/build-push-action@v2.5.0 + uses: docker/build-push-action@v7 with: context: . + file: standalone.Dockerfile push: true tags: ghcr.io/${{ github.repository }}:standalone-${{ env.version }}${{ env.suffix }} diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 1f071c8..d3ab20d 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -42,11 +42,11 @@ jobs: - name: build mdBook run: mdbook build docs/ - name: Setup Pages - uses: actions/configure-pages@v2 + uses: actions/configure-pages@v4 - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v2 with: path: 'docs/book/html' - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v1 + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 63aeeab..e8deb99 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,13 +17,13 @@ env: jobs: build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: install lua run: sudo apt install -y liblua5.3-dev - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up cargo cache uses: actions/cache@v3 continue-on-error: false diff --git a/Cargo.toml b/Cargo.toml index 545f997..2a5443c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,4 +57,4 @@ version = "0.14" version = "0.2" [profile.release] -debug = true +debug = "line-tables-only" diff --git a/Dockerfile b/Dockerfile index f2ec249..36fd048 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,38 @@ -FROM ubuntu:20.04 -RUN apt update && \ - apt install -y openssl liblua5.3-0 -ADD target/release/overload /usr/bin/overload -RUN chmod +x /usr/bin/overload +# Build stage +FROM rust:1.96.0-slim-trixie AS builder + +# Install build dependencies +RUN apt-get update && apt-get install -y \ + pkg-config \ + openssl \ + libssl-dev \ + liblua5.3-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/src/overload +COPY . . + +# Build the application +RUN cargo build --features "cluster" --release + +# Runtime stage +FROM debian:trixie-slim + +# Install runtime dependencies +RUN apt-get update && apt-get install -y \ + ca-certificates \ + libssl3 \ + openssl \ + liblua5.3-0 \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/bin + +# Copy the binary from the builder stage +COPY --from=builder /usr/src/overload/target/release/overload . + +# Expose the port the app runs on EXPOSE 3030 -ENTRYPOINT /usr/bin/overload + +# Set the startup command +CMD ["/usr/bin/overload"] \ No newline at end of file diff --git a/standalone.Dockerfile b/standalone.Dockerfile new file mode 100644 index 0000000..ba98faa --- /dev/null +++ b/standalone.Dockerfile @@ -0,0 +1,38 @@ +# Build stage +FROM rust:1.96.0-slim-trixie AS builder + +# Install build dependencies +RUN apt-get update && apt-get install -y \ + pkg-config \ + openssl \ + libssl-dev \ + liblua5.3-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/src/overload +COPY . . + +# Build the application +RUN cargo build --release + +# Runtime stage +FROM debian:trixie-slim + +# Install runtime dependencies +RUN apt-get update && apt-get install -y \ + ca-certificates \ + libssl3 \ + openssl \ + liblua5.3-0 \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/bin + +# Copy the binary from the builder stage +COPY --from=builder /usr/src/overload/target/release/overload . + +# Expose the port the app runs on +EXPOSE 3030 + +# Set the startup command +CMD ["/usr/bin/overload"] \ No newline at end of file