mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-12-16 09:27:52 +00:00
This commit is contained in:
51
.github/workflows/rust.yml
vendored
51
.github/workflows/rust.yml
vendored
@@ -5,12 +5,23 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- 'RUST'
|
- 'RUST'
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: docker.io
|
||||||
|
IMAGE_NAME: ultradesu/outfleet
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
build:
|
||||||
runs-on: self-hosted
|
runs-on: ubuntu-latest
|
||||||
needs: test-build
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Extract version from Cargo.toml
|
||||||
|
id: extract_version
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
|
||||||
|
echo "cargo_version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "Extracted version: $VERSION"
|
||||||
|
|
||||||
- name: Set build variables
|
- name: Set build variables
|
||||||
id: vars
|
id: vars
|
||||||
@@ -20,38 +31,24 @@ jobs:
|
|||||||
echo "build_date=$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
|
echo "build_date=$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
|
||||||
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
|
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Extract version from Cargo.toml
|
|
||||||
id: extract_version
|
|
||||||
run: |
|
|
||||||
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
|
|
||||||
echo "cargo_version=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Log in to Docker Hub
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
push: true
|
push: true
|
||||||
cache-from: |
|
cache-from: type=gha
|
||||||
type=registry,ref=ultradesu/outfleet:deps-cache
|
cache-to: type=gha,mode=max
|
||||||
type=registry,ref=ultradesu/outfleet:builder-cache
|
|
||||||
type=registry,ref=ultradesu/outfleet:rust-buildcache
|
|
||||||
cache-to: |
|
|
||||||
type=registry,ref=ultradesu/outfleet:deps-cache,mode=max
|
|
||||||
type=registry,ref=ultradesu/outfleet:builder-cache,mode=max
|
|
||||||
type=registry,ref=ultradesu/outfleet:rust-buildcache,mode=max
|
|
||||||
build-args: |
|
build-args: |
|
||||||
GIT_COMMIT=${{ steps.vars.outputs.sha_full }}
|
GIT_COMMIT=${{ steps.vars.outputs.sha_full }}
|
||||||
GIT_COMMIT_SHORT=${{ steps.vars.outputs.sha_short }}
|
GIT_COMMIT_SHORT=${{ steps.vars.outputs.sha_short }}
|
||||||
@@ -59,6 +56,6 @@ jobs:
|
|||||||
BRANCH_NAME=${{ steps.vars.outputs.branch_name }}
|
BRANCH_NAME=${{ steps.vars.outputs.branch_name }}
|
||||||
CARGO_VERSION=${{ steps.extract_version.outputs.cargo_version }}
|
CARGO_VERSION=${{ steps.extract_version.outputs.cargo_version }}
|
||||||
tags: |
|
tags: |
|
||||||
ultradesu/outfleet:rs-${{ steps.extract_version.outputs.cargo_version }}
|
${{ env.IMAGE_NAME }}:rs-${{ steps.extract_version.outputs.cargo_version }}
|
||||||
ultradesu/outfleet:rs-${{ steps.extract_version.outputs.cargo_version }}-${{ steps.vars.outputs.sha_short }}
|
${{ env.IMAGE_NAME }}:rs-${{ steps.extract_version.outputs.cargo_version }}-${{ steps.vars.outputs.sha_short }}
|
||||||
ultradesu/outfleet:rust-latest
|
${{ env.IMAGE_NAME }}:rust-latest
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "xray-admin"
|
name = "xray-admin"
|
||||||
version = "0.1.1"
|
version = "0.1.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
39
Dockerfile
39
Dockerfile
@@ -1,6 +1,5 @@
|
|||||||
# Cargo dependencies stage
|
# Use cargo-chef for dependency caching
|
||||||
FROM rust:1.90-slim AS deps
|
FROM lukemathwalker/cargo-chef:0.1.68-rust-1.90-slim AS chef
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install system dependencies needed for building
|
# Install system dependencies needed for building
|
||||||
@@ -10,20 +9,13 @@ RUN apt-get update && apt-get install -y \
|
|||||||
protobuf-compiler \
|
protobuf-compiler \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy only dependency specification files
|
# Recipe preparation stage
|
||||||
COPY Cargo.toml Cargo.lock ./
|
FROM chef AS planner
|
||||||
|
COPY . .
|
||||||
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
|
|
||||||
# Create dummy source to build dependencies
|
# Dependency building stage
|
||||||
RUN mkdir -p src && \
|
FROM chef AS builder
|
||||||
echo "fn main() {}" > src/main.rs && \
|
|
||||||
echo "pub fn lib() {}" > src/lib.rs
|
|
||||||
|
|
||||||
# Build dependencies - this layer will be cached unless Cargo.toml changes
|
|
||||||
RUN cargo build --release && \
|
|
||||||
rm -rf src target/release/deps/xray_admin* target/release/xray-admin*
|
|
||||||
|
|
||||||
# Build stage
|
|
||||||
FROM deps AS builder
|
|
||||||
|
|
||||||
# Build arguments
|
# Build arguments
|
||||||
ARG GIT_COMMIT="development"
|
ARG GIT_COMMIT="development"
|
||||||
@@ -39,15 +31,16 @@ ENV BUILD_DATE=${BUILD_DATE}
|
|||||||
ENV BRANCH_NAME=${BRANCH_NAME}
|
ENV BRANCH_NAME=${BRANCH_NAME}
|
||||||
ENV CARGO_VERSION=${CARGO_VERSION}
|
ENV CARGO_VERSION=${CARGO_VERSION}
|
||||||
|
|
||||||
# Copy actual source code
|
# Copy recipe and build dependencies (cached layer)
|
||||||
COPY src ./src
|
COPY --from=planner /app/recipe.json recipe.json
|
||||||
COPY static ./static
|
RUN cargo chef cook --release --recipe-path recipe.json
|
||||||
|
|
||||||
# Build the application (dependencies are already compiled)
|
# Copy source and build application
|
||||||
RUN cargo build --release
|
COPY . .
|
||||||
|
RUN cargo build --release --locked
|
||||||
|
|
||||||
# Runtime stage - minimal Debian image
|
# Runtime stage - minimal Ubuntu image for glibc compatibility
|
||||||
FROM debian:bookworm-slim AS runtime
|
FROM ubuntu:24.04 AS runtime
|
||||||
|
|
||||||
# Build arguments (needed for runtime stage)
|
# Build arguments (needed for runtime stage)
|
||||||
ARG GIT_COMMIT="development"
|
ARG GIT_COMMIT="development"
|
||||||
|
|||||||
Reference in New Issue
Block a user