Environment Variable in build time
I’m using Prisma Client to connect to my database from Space. However, I’m encountering issues with environment variables: they only seem to be available when the app is actually running (inside entrypoint.sh). This means I can’t run prisma generate at build time, and at runtime, I’m hitting a directory permission error. I even tried running the application as root to bypass the issue, but it seems Space doesn’t allow that.Here are some code for context:Dockerfile:FROM python:3.12.5-bookworm
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 2710 user

# Switch to the "user" user
USER user
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH

WORKDIR $HOME/src
COPY --chown=user . $HOME/src
RUN mkdir .ipfs
RUN chmod 777 $HOME/src/.ipfs
RUN chmod 777 $HOME

RUN pip install --upgrade pip
RUN pip install -r requirements.txt

// RUN prisma generate

RUN chmod +x ./entrypoint.sh

EXPOSE 7860

ENTRYPOINT [ "./entrypoint.sh" ]Entrypoint:#!/bin/sh

python main.pySome other docker hosting has BUILD_ENV which provide env variable for build time.
2024-08-29T08:32:03Z
I don’t use Docker, so I don’t know much about it, but I’ve found something that looks like it.huggingface.coDocker SpacesWe’re on a journey to advance and democratize artificial intelligence through open source and open science.Secrets and Variables ManagementYou can manage a Space’s environment variables in the Space Settings. Read morehere.VariablesBuildtimeVariables are passed asbuild-args when building your Docker Space. ReadDocker’s dedicated documentationfor a complete guide on how to use this in the Dockerfile.
2024-08-29T10:53:23Z
John6666:en building your DocBut Huggingface space don’t let us change the run command of the docker (thebuild-argswhen buiding). It only let us change the env at runtime.I try toprintenvat runtime and buildtime and only see Spaces Variables (huggingface env setting) at runtime. Nor buildtime
2024-08-29T11:03:13Z
Is that just a bug…?Basically, there are quite a few features that aren’t used very often that are buggy. No one reports it, so none of the developers notice…I don’t know where to report bugs in Spaces.HF doesn’t have a DM, so the only way is to send a mentions to someone who seems to have admin rights, or hit up Discord, or open a Discussion with a randomly selected HF staff repo.huggingface.co@bartowski on Hugging Face: "@victor (is this the only way to "DM" on HF?)...We’re on a journey to advance and democratize artificial intelligence through open source and open science.P.S.By the way, what I would do is either find another alternative tool because I’m too lazy to wait, or combine multiple somethings to somehow make it work.It’s not pretty, but it’s the fast way.
2024-08-30T05:57:56Z
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.