Spaces:
Running
Running
Update Dockerfile
Browse files1234346789101112131415161718192056789101112131415161718192021222324256 unmodified lines3233343738353640414237383940414243444546474849505152535455565758596061626345464764FROM postgres:17
ENV POSTGRES_USER=adminENV POSTGRES_DB=appdbARG SOURCE_BRANCH=main
# PostgreSQL runtime data directory: use the Space local disk.ENV PGDATA=/home/user/pgdata
# Mounted storage bucket directories: backups, user files, exports, generated files.ENV DATA_DIR=/dataENV BACKUP_DIR=/data/backupsENV USER_FILE_DIR=/data/filesENV EXPORT_DIR=/data/exportsENV GENERATED_DIR=/data/generated
# Automatic pg_dump interval, default: 1 hour.ENV BACKUP_INTERVAL_SECONDS=3600
# Adminer is installed for future use or manual local debugging.ENV ADMINER_VERSION=4.8.1ENV SOURCE_BRANCH=${SOURCE_BRANCH} \ SOURCE_REPOSITORY=CaPaCaptain/PostgreSQL_general_HF \ POSTGRES_USER=admin \ POSTGRES_DB=appdb \ PGDATA=/home/user/pgdata \ DATA_DIR=/data \ BACKUP_DIR=/data/backups \ USER_FILE_DIR=/data/files \ EXPORT_DIR=/data/exports \ GENERATED_DIR=/data/generated \ BACKUP_INTERVAL_SECONDS=3600 \ ADMINER_VERSION=4.8.1
RUN apt-get update && apt-get install -y --no-install-recommends \ git \ curl \ ca-certificates \ coreutils \ php-cli \ php-pgsql \ php-mysql \6 unmodified linesRUN curl -L -o /adminer.php \ https://github.com/vrana/adminer/releases/download/v${ADMINER_VERSION}/adminer-${ADMINER_VERSION}.php
COPY requirements.txt /requirements.txtRUN pip3 install --break-system-packages -r /requirements.txtWORKDIR /bootstrap
COPY api.py /api.pyCOPY start.sh /start.shRUN chmod +x /start.sh# GITHUB_TOKEN is provided by Hugging Face as a runtime Secret.# On every container start, fetch the latest selected GitHub branch, copy the# deployable HF_files package into /app, remove the token from the environment,# validate the application, and then launch PostgreSQL + FastAPI.CMD ["bash", "-lc", "set -euo pipefail; \ : \"${GITHUB_TOKEN:?GITHUB_TOKEN is required as a Hugging Face Space Secret}\"; \ : \"${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required as a Hugging Face Space Secret}\"; \ TOKEN=\"${GITHUB_TOKEN}\"; \ AUTH=\"$(printf 'x-access-token:%s' \"${TOKEN}\" | base64 | tr -d '\\n')\"; \ rm -rf /tmp/postgresql-general /app; \ git -c http.extraHeader=\"Authorization: Basic ${AUTH}\" clone \ --depth 1 \ --branch \"${SOURCE_BRANCH}\" \ \"https://github.com/${SOURCE_REPOSITORY}.git\" \ /tmp/postgresql-general; \ mkdir -p /app; \ cp -a /tmp/postgresql-general/HF_files/. /app/; \ rm -rf /tmp/postgresql-general; \ unset GITHUB_TOKEN TOKEN AUTH; \ python3 -m pip install --break-system-packages --no-cache-dir -r /app/requirements.txt; \ chmod +x /app/start.sh; \ python3 -m compileall -q /app; \ cd /app; \ python3 -c \"from platform_app.main import app; paths={r.path for r in app.routes}; required={'/api/health','/admin/projects','/api/flowtrace','/api/flowtrace-portfolio','/api/openclaw/memories','/api/files','/api/rss/articles'}; missing=required-paths; assert not missing, f'missing routes: {sorted(missing)}'\"; \ exec /app/start.sh"]
EXPOSE 5432EXPOSE 7860
CMD ["/start.sh"]EXPOSE 7860Dockerfile+42-25