Switch Space Dockerfile to OpenPost (pre-built image) after repeated Postiz build OOMs
Browse files- Dockerfile +26 -73
Dockerfile
CHANGED
|
@@ -1,75 +1,28 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
# Set default env variables for local Postgres & Redis inside the container.
|
| 6 |
-
# These can be overridden by Space secrets/variables at runtime.
|
| 7 |
-
ENV DATABASE_URL="postgresql://postiz-user:postiz-password@127.0.0.1:5432/postiz-db-local"
|
| 8 |
-
ENV REDIS_URL="redis://127.0.0.1:6379"
|
| 9 |
-
ENV JWT_SECRET="huggingface-space-secret-jwt-key"
|
| 10 |
-
ENV FRONTEND_URL="http://localhost:7860"
|
| 11 |
-
ENV MAIN_URL="http://localhost:7860"
|
| 12 |
-
ENV NEXT_PUBLIC_BACKEND_URL="http://localhost:7860/api"
|
| 13 |
-
ENV BACKEND_INTERNAL_URL="http://localhost:3000"
|
| 14 |
-
ENV IS_GENERAL="true"
|
| 15 |
-
ENV DISABLE_REGISTRATION="false"
|
| 16 |
-
# Skips generating production sourcemaps (see apps/frontend/next.config.js) —
|
| 17 |
-
# Sentry isn't configured here (no SENTRY_AUTH_TOKEN) and generating full
|
| 18 |
-
# client+server sourcemaps was pushing the frontend build over the Space's
|
| 19 |
-
# memory limit.
|
| 20 |
-
ENV HF_SPACE_BUILD="true"
|
| 21 |
-
|
| 22 |
-
# Avoid interactive prompts from debconf/apt
|
| 23 |
-
ARG DEBIAN_FRONTEND=noninteractive
|
| 24 |
-
|
| 25 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 26 |
-
g++ \
|
| 27 |
-
make \
|
| 28 |
-
python3-pip \
|
| 29 |
-
bash \
|
| 30 |
-
nginx \
|
| 31 |
-
postgresql \
|
| 32 |
-
postgresql-contrib \
|
| 33 |
-
redis-server \
|
| 34 |
-
git \
|
| 35 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 36 |
-
|
| 37 |
-
RUN addgroup --system www \
|
| 38 |
-
&& adduser --system --ingroup www --home /www --shell /usr/sbin/nologin www \
|
| 39 |
-
&& mkdir -p /www \
|
| 40 |
-
&& chown -R www:www /www /var/lib/nginx
|
| 41 |
-
|
| 42 |
-
RUN npm --no-update-notifier --no-fund --global install pnpm@10.6.1 pm2
|
| 43 |
-
|
| 44 |
-
WORKDIR /app
|
| 45 |
-
|
| 46 |
-
COPY . /app
|
| 47 |
-
COPY var/docker/nginx.conf /etc/nginx/nginx.conf
|
| 48 |
-
|
| 49 |
-
RUN pnpm install --frozen-lockfile
|
| 50 |
-
|
| 51 |
-
# Build the frontend/backend/orchestrator so `pnpm run pm2` has something to run.
|
| 52 |
-
# Built as separate RUN steps (rather than the combined `pnpm run build`) so each
|
| 53 |
-
# process fully exits and releases its memory before the next one starts, and the
|
| 54 |
-
# frontend forces the classic webpack build instead of Next.js 16's default
|
| 55 |
-
# Turbopack build, which was OOM-killing the container on HF's cpu-basic hardware.
|
| 56 |
-
RUN NODE_OPTIONS="--max-old-space-size=3072" pnpm --workspace-concurrency=1 --filter ./apps/backend --filter ./apps/orchestrator run build
|
| 57 |
-
|
| 58 |
-
# Diagnostic: report the actual memory ceiling the build container sees,
|
| 59 |
-
# since the frontend build has been OOMKilled at the very start of
|
| 60 |
-
# "Creating an optimized production build" regardless of bundler or
|
| 61 |
-
# sourcemap settings, which points at a much smaller limit than expected.
|
| 62 |
-
RUN echo "=== free -h ===" && free -h || true; \
|
| 63 |
-
echo "=== cgroup v2 memory.max ===" && cat /sys/fs/cgroup/memory.max 2>/dev/null || true; \
|
| 64 |
-
echo "=== cgroup v1 memory.limit_in_bytes ===" && cat /sys/fs/cgroup/memory/memory.limit_in_bytes 2>/dev/null || true; \
|
| 65 |
-
echo "=== nproc ===" && nproc || true
|
| 66 |
-
|
| 67 |
-
RUN NODE_OPTIONS="--max-old-space-size=3072" pnpm --filter ./apps/frontend exec next build --webpack
|
| 68 |
-
|
| 69 |
-
# Make scripts executable
|
| 70 |
-
RUN chmod +x /app/var/docker/start.sh /app/var/docker/backup.sh
|
| 71 |
-
|
| 72 |
-
# Hugging Face Docker Spaces route all traffic to this port (see README app_port)
|
| 73 |
EXPOSE 7860
|
| 74 |
-
|
| 75 |
-
CMD ["/app/var/docker/start.sh"]
|
|
|
|
| 1 |
+
# OpenPost — lightweight self-hosted social media scheduler.
|
| 2 |
+
# Uses the official pre-built image, so Hugging Face only pulls layers
|
| 3 |
+
# instead of compiling anything (this Space's previous Postiz-based
|
| 4 |
+
# deployment consistently OOMKilled during its Next.js frontend build
|
| 5 |
+
# on the free cpu-basic tier).
|
| 6 |
+
FROM ghcr.io/getopenpost/openpost:latest
|
| 7 |
+
|
| 8 |
+
# Hugging Face Docker Spaces route all traffic to this port (see README app_port).
|
| 9 |
+
ENV OPENPOST_PORT="7860"
|
| 10 |
+
ENV OPENPOST_EDITION="selfhost"
|
| 11 |
+
|
| 12 |
+
# Public URL of this Space — required for CORS/redirects and WebAuthn/passkeys.
|
| 13 |
+
ENV OPENPOST_APP_URL="https://leon4gr45-postio.hf.space"
|
| 14 |
+
ENV OPENPOST_PUBLIC_URL="https://leon4gr45-postio.hf.space"
|
| 15 |
+
|
| 16 |
+
# SQLite + local media, matching OpenPost's default single-container setup.
|
| 17 |
+
# Note: the Space's filesystem is ephemeral on the free tier, so this data
|
| 18 |
+
# does not survive a Space restart/rebuild unless persistent storage is
|
| 19 |
+
# enabled in the Space's Settings.
|
| 20 |
+
ENV OPENPOST_DATABASE_DRIVER="sqlite"
|
| 21 |
+
ENV OPENPOST_DATABASE_PATH="/data/db/openpost.db"
|
| 22 |
+
ENV OPENPOST_STORAGE_DRIVER="local"
|
| 23 |
+
ENV OPENPOST_MEDIA_PATH="/data/media"
|
| 24 |
+
|
| 25 |
+
# OPENPOST_JWT_SECRET and OPENPOST_ENCRYPTION_KEY are set as Space secrets
|
| 26 |
+
# (Settings -> Variables and secrets), not baked in here.
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
EXPOSE 7860
|
|
|
|
|
|