# ============================================================================= # Sub2API on HuggingFace Spaces # ============================================================================= # Alpine-based single container: PG + Redis + sub2api # All config files are COPY'd (no heredoc - HF build env doesn't support it) # Binary downloaded at runtime from GitHub (cached in persistent /data) # ============================================================================= FROM alpine:3.21 # Install PostgreSQL, Redis, supervisord, and tools RUN apk add --no-cache \ postgresql postgresql-contrib \ redis \ supervisor \ bash \ curl \ wget \ openssl \ ca-certificates \ tzdata \ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone # Data directories RUN mkdir -p /data/sub2api /data/postgres /data/redis \ /var/log/supervisor /run/postgresql # Copy config files (all created with LF line endings) COPY postgresql.conf /etc/postgresql/postgresql.conf COPY pg_hba.conf /etc/postgresql/pg_hba.conf COPY redis.conf /etc/redis.conf COPY supervisord.conf /etc/supervisord.conf COPY start.sh /app/start.sh # Ensure start.sh has LF line endings and is executable RUN sed -i 's/\r$//' /app/start.sh && chmod +x /app/start.sh EXPOSE 7860 ENV SERVER_PORT=7860 ENV DATA_DIR=/data/sub2api ENV TZ=Asia/Shanghai ENV POSTGRES_PASSWORD=sub2api2026 ENV POSTGRES_USER=sub2api ENV POSTGRES_DB=sub2api CMD ["supervisord", "-c", "/etc/supervisord.conf"]