mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-12-16 17:37:51 +00:00
This commit is contained in:
41
Dockerfile
41
Dockerfile
@@ -1,6 +1,5 @@
|
||||
# Cargo dependencies stage
|
||||
FROM rust:1.90-slim AS deps
|
||||
|
||||
# Use cargo-chef for dependency caching
|
||||
FROM lukemathwalker/cargo-chef:0.1.68-rust-1.90-slim AS chef
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies needed for building
|
||||
@@ -10,20 +9,13 @@ RUN apt-get update && apt-get install -y \
|
||||
protobuf-compiler \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy only dependency specification files
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
# Recipe preparation stage
|
||||
FROM chef AS planner
|
||||
COPY . .
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
# Create dummy source to build dependencies
|
||||
RUN mkdir -p src && \
|
||||
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
|
||||
# Dependency building stage
|
||||
FROM chef AS builder
|
||||
|
||||
# Build arguments
|
||||
ARG GIT_COMMIT="development"
|
||||
@@ -39,15 +31,16 @@ ENV BUILD_DATE=${BUILD_DATE}
|
||||
ENV BRANCH_NAME=${BRANCH_NAME}
|
||||
ENV CARGO_VERSION=${CARGO_VERSION}
|
||||
|
||||
# Copy actual source code
|
||||
COPY src ./src
|
||||
COPY static ./static
|
||||
# Copy recipe and build dependencies (cached layer)
|
||||
COPY --from=planner /app/recipe.json recipe.json
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
# Build the application (dependencies are already compiled)
|
||||
RUN cargo build --release
|
||||
# Copy source and build application
|
||||
COPY . .
|
||||
RUN cargo build --release --locked
|
||||
|
||||
# Runtime stage - minimal Debian image
|
||||
FROM debian:bookworm-slim AS runtime
|
||||
# Runtime stage - minimal Ubuntu image for glibc compatibility
|
||||
FROM ubuntu:24.04 AS runtime
|
||||
|
||||
# Build arguments (needed for runtime stage)
|
||||
ARG GIT_COMMIT="development"
|
||||
@@ -89,4 +82,4 @@ USER outfleet
|
||||
|
||||
EXPOSE 8081
|
||||
|
||||
CMD ["/app/xray-admin", "--host", "0.0.0.0"]
|
||||
CMD ["/app/xray-admin", "--host", "0.0.0.0"]
|
||||
Reference in New Issue
Block a user