File size: 1,776 Bytes
633275d 229acac 633275d b498442 633275d b498442 fe77730 633275d 229acac 3c5edb9 ed7360e bc1943b fe20cf4 229acac b498442 fe77730 b498442 3c5edb9 fe77730 b498442 229acac 1f46dbb fe20cf4 229acac b498442 229acac b498442 fe77730 b498442 bc1943b b498442 bc1943b 229acac bc1943b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | FROM ubuntu:24.04
# Disable interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# 1. Install dependencies (added procps for pgrep/pkill supervision)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
jq \
msmtp \
msmtp-mta \
ca-certificates \
tar \
rsync \
bash \
procps \
python3 \
python3-pip \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
# 2. Setup non-root user (UID 1000)
RUN userdel -r ubuntu && useradd -m -u 1000 user
WORKDIR /app
# 3. Setup Python Virtual Environment and PATH
RUN python3 -m venv /app/venv
ENV PATH="/app/bin:/app/venv/bin:$PATH"
RUN pip install --no-cache-dir fastapi uvicorn requests pydantic
# 4. Download & Install ApexKit Binary into /app/bin (User-writable)
RUN echo "Downloading latest public release archive..." && \
LATEST_URL=$(curl -s https://api.github.com/repos/deniskipeles/apexkit/releases/latest | \
jq -r '.assets[] | select(.name | contains("linux-gnu.tar.gz")) | .browser_download_url') && \
echo "URL: $LATEST_URL" && \
curl -L -o apexkit.tar.gz "$LATEST_URL" && \
tar -xzf apexkit.tar.gz && \
mkdir -p /app/bin && \
mv apexkit /app/bin/apexkit && \
chmod +x /app/bin/apexkit && \
ln -sf /app/bin/apexkit /usr/local/bin/apexkit && \
rm apexkit.tar.gz
# 5. Copy FastAPI Application
COPY --chown=user:user main.py /app/main.py
# 6. Setup storage directories & ensure full ownership by user
RUN mkdir -p /app/bin /app/storage /data/storage /data/bin && \
chown -R user:user /app /data
# 7. Copy and prepare entrypoint script
COPY --chown=user:user entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
USER user
ENV PORT=7860
ENTRYPOINT ["/app/entrypoint.sh"] |