darkfire514 commited on
Commit
de15f88
·
verified ·
1 Parent(s): dd72944

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -25
Dockerfile CHANGED
@@ -1,27 +1,25 @@
1
  FROM postgres:17
2
 
3
- ENV POSTGRES_USER=admin
4
- ENV POSTGRES_DB=appdb
5
 
6
- # PostgreSQL runtime data directory: use the Space local disk.
7
- ENV PGDATA=/home/user/pgdata
8
-
9
- # Mounted storage bucket directories: backups, user files, exports, generated files.
10
- ENV DATA_DIR=/data
11
- ENV BACKUP_DIR=/data/backups
12
- ENV USER_FILE_DIR=/data/files
13
- ENV EXPORT_DIR=/data/exports
14
- ENV GENERATED_DIR=/data/generated
15
-
16
- # Automatic pg_dump interval, default: 1 hour.
17
- ENV BACKUP_INTERVAL_SECONDS=3600
18
-
19
- # Adminer is installed for future use or manual local debugging.
20
- ENV ADMINER_VERSION=4.8.1
21
 
22
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
23
  curl \
24
  ca-certificates \
 
25
  php-cli \
26
  php-pgsql \
27
  php-mysql \
@@ -34,14 +32,33 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
34
  RUN curl -L -o /adminer.php \
35
  https://github.com/vrana/adminer/releases/download/v${ADMINER_VERSION}/adminer-${ADMINER_VERSION}.php
36
 
37
- COPY requirements.txt /requirements.txt
38
- RUN pip3 install --break-system-packages -r /requirements.txt
39
 
40
- COPY api.py /api.py
41
- COPY start.sh /start.sh
42
- RUN chmod +x /start.sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  EXPOSE 5432
45
- EXPOSE 7860
46
-
47
- CMD ["/start.sh"]
 
1
  FROM postgres:17
2
 
3
+ ARG SOURCE_BRANCH=main
 
4
 
5
+ ENV SOURCE_BRANCH=${SOURCE_BRANCH} \
6
+ SOURCE_REPOSITORY=CaPaCaptain/PostgreSQL_general_HF \
7
+ POSTGRES_USER=admin \
8
+ POSTGRES_DB=appdb \
9
+ PGDATA=/home/user/pgdata \
10
+ DATA_DIR=/data \
11
+ BACKUP_DIR=/data/backups \
12
+ USER_FILE_DIR=/data/files \
13
+ EXPORT_DIR=/data/exports \
14
+ GENERATED_DIR=/data/generated \
15
+ BACKUP_INTERVAL_SECONDS=3600 \
16
+ ADMINER_VERSION=4.8.1
 
 
 
17
 
18
  RUN apt-get update && apt-get install -y --no-install-recommends \
19
+ git \
20
  curl \
21
  ca-certificates \
22
+ coreutils \
23
  php-cli \
24
  php-pgsql \
25
  php-mysql \
 
32
  RUN curl -L -o /adminer.php \
33
  https://github.com/vrana/adminer/releases/download/v${ADMINER_VERSION}/adminer-${ADMINER_VERSION}.php
34
 
35
+ WORKDIR /bootstrap
 
36
 
37
+ # GITHUB_TOKEN is provided by Hugging Face as a runtime Secret.
38
+ # On every container start, fetch the latest selected GitHub branch, copy the
39
+ # deployable HF_files package into /app, remove the token from the environment,
40
+ # validate the application, and then launch PostgreSQL + FastAPI.
41
+ CMD ["bash", "-lc", "set -euo pipefail; \
42
+ : \"${GITHUB_TOKEN:?GITHUB_TOKEN is required as a Hugging Face Space Secret}\"; \
43
+ : \"${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required as a Hugging Face Space Secret}\"; \
44
+ TOKEN=\"${GITHUB_TOKEN}\"; \
45
+ AUTH=\"$(printf 'x-access-token:%s' \"${TOKEN}\" | base64 | tr -d '\\n')\"; \
46
+ rm -rf /tmp/postgresql-general /app; \
47
+ git -c http.extraHeader=\"Authorization: Basic ${AUTH}\" clone \
48
+ --depth 1 \
49
+ --branch \"${SOURCE_BRANCH}\" \
50
+ \"https://github.com/${SOURCE_REPOSITORY}.git\" \
51
+ /tmp/postgresql-general; \
52
+ mkdir -p /app; \
53
+ cp -a /tmp/postgresql-general/HF_files/. /app/; \
54
+ rm -rf /tmp/postgresql-general; \
55
+ unset GITHUB_TOKEN TOKEN AUTH; \
56
+ python3 -m pip install --break-system-packages --no-cache-dir -r /app/requirements.txt; \
57
+ chmod +x /app/start.sh; \
58
+ python3 -m compileall -q /app; \
59
+ cd /app; \
60
+ 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)}'\"; \
61
+ exec /app/start.sh"]
62
 
63
  EXPOSE 5432
64
+ EXPOSE 7860