Basic Rest API implementation
This commit is contained in:
55
Dockerfile
Normal file
55
Dockerfile
Normal file
@ -0,0 +1,55 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Prevent interactive prompts
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
curl \
|
||||
wget \
|
||||
jq \
|
||||
pwgen \
|
||||
bc \
|
||||
zip \
|
||||
unzip \
|
||||
lsof \
|
||||
gnupg \
|
||||
lsb-release \
|
||||
systemctl \
|
||||
iptables \
|
||||
iproute2 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create working directory
|
||||
WORKDIR /etc/hysteria
|
||||
|
||||
# Copy requirements first (for better caching)
|
||||
COPY requirements.txt .
|
||||
|
||||
# Create and activate virtual environment, install dependencies
|
||||
RUN python3 -m venv /etc/hysteria/hysteria2_venv && \
|
||||
/etc/hysteria/hysteria2_venv/bin/pip install --no-cache-dir --upgrade pip && \
|
||||
/etc/hysteria/hysteria2_venv/bin/pip install --no-cache-dir -r requirements.txt && \
|
||||
/etc/hysteria/hysteria2_venv/bin/pip install --no-cache-dir fastapi uvicorn python-multipart
|
||||
|
||||
# Copy application files
|
||||
COPY . /etc/hysteria/
|
||||
|
||||
# Make scripts executable
|
||||
RUN find /etc/hysteria/core/scripts -type f -name "*.sh" -exec chmod +x {} \; && \
|
||||
find /etc/hysteria/core/scripts -type f -name "*.py" -exec chmod +x {} \; && \
|
||||
chmod +x /etc/hysteria/menu.sh
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 8000 443 80
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
|
||||
# Start FastAPI server
|
||||
CMD ["/etc/hysteria/hysteria2_venv/bin/uvicorn", "core.api:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||
Reference in New Issue
Block a user