Spaces:
Runtime error
Runtime error
| FROM postgres:15 | |
| # Install utilities | |
| RUN apt-get update && apt-get install -y \ | |
| wget \ | |
| unzip \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install pgweb | |
| RUN wget https://github.com/sosedoff/pgweb/releases/download/v0.14.1/pgweb_linux_amd64.zip \ | |
| && unzip pgweb_linux_amd64.zip \ | |
| && mv pgweb_linux_amd64 /usr/local/bin/pgweb \ | |
| && rm pgweb_linux_amd64.zip | |
| # Create a directory for the custom start script | |
| WORKDIR /app | |
| # Copy the start script | |
| COPY start.sh /app/start.sh | |
| RUN chmod +x /app/start.sh | |
| # Set the user to postgres (UID 999) which is the default for this image | |
| # However, HF Spaces runs as UID 1000. | |
| # We need to ensure permissions are correct for /var/lib/postgresql/data | |
| # The official image creates a volume at /var/lib/postgresql/data | |
| # We will let the start script handle the user switching or just run as the default user if possible. | |
| # HF Spaces overrides the user to 1000. | |
| # We need to make sure the data directory is writable by UID 1000. | |
| # Install Node.js and n8n | |
| RUN apt-get update && apt-get install -y \ | |
| curl \ | |
| gnupg \ | |
| && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ | |
| && apt-get install -y nodejs \ | |
| && npm install -g n8n \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create the data directory and give permissions to UID 1000 | |
| # We create a user with UID 1000 to match HF Spaces default and avoid root errors | |
| RUN useradd -m -u 1000 hf_user | |
| RUN mkdir -p /var/lib/postgresql/data && \ | |
| chown -R hf_user:hf_user /var/lib/postgresql/data && \ | |
| chmod 700 /var/lib/postgresql/data | |
| # Switch to the non-root user | |
| USER hf_user | |
| # Expose the port for n8n (HF Spaces expects 7860) | |
| EXPOSE 7860 | |
| # Set the entrypoint to our custom script | |
| CMD ["/app/start.sh"] ......... | |