Spaces:
Sleeping
Sleeping
Fix the get secrets and update env variables
Browse files### Fix the get secrets and update env variables
- Dockerfile +12 -7
Dockerfile
CHANGED
@@ -1,15 +1,21 @@
|
|
1 |
FROM python:3.11.9-slim
|
2 |
|
3 |
|
4 |
-
# Expose the secret SECRETS at
|
5 |
RUN --mount=type=secret,id=REDIS_URL,mode=0444,required=true
|
6 |
RUN --mount=type=secret,id=REDIS_USERNAME,mode=0444,required=true
|
7 |
RUN --mount=type=secret,id=REDIS_PASSWORD,mode=0444,required=true
|
8 |
|
9 |
-
#
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Copy requirements file
|
15 |
COPY requirements_docker.txt .
|
@@ -31,5 +37,4 @@ WORKDIR /
|
|
31 |
EXPOSE 9000
|
32 |
|
33 |
# Start application
|
34 |
-
|
35 |
-
CMD ["uvicorn", "src.api.api:app", "--host", "0.0.0.0", "--port", "9000"]
|
|
|
1 |
FROM python:3.11.9-slim
|
2 |
|
3 |
|
4 |
+
# Expose the secret SECRETS at build-time
|
5 |
RUN --mount=type=secret,id=REDIS_URL,mode=0444,required=true
|
6 |
RUN --mount=type=secret,id=REDIS_USERNAME,mode=0444,required=true
|
7 |
RUN --mount=type=secret,id=REDIS_PASSWORD,mode=0444,required=true
|
8 |
|
9 |
+
# Read secrets and set environment variables
|
10 |
+
RUN export REDIS_URL=$(cat /run/secrets/REDIS_URL) \
|
11 |
+
&& export REDIS_USERNAME=$(cat /run/secrets/REDIS_USERNAME) \
|
12 |
+
&& export REDIS_PASSWORD=$(cat /run/secrets/REDIS_PASSWORD) \
|
13 |
+
&& echo "REDIS_URL=$REDIS_URL" >> /etc/environment \
|
14 |
+
&& echo "REDIS_USERNAME=$REDIS_USERNAME" >> /etc/environment \
|
15 |
+
&& echo "REDIS_PASSWORD=$REDIS_PASSWORD" >> /etc/environment
|
16 |
+
|
17 |
+
# Source the environment file
|
18 |
+
RUN . /etc/environment
|
19 |
|
20 |
# Copy requirements file
|
21 |
COPY requirements_docker.txt .
|
|
|
37 |
EXPOSE 9000
|
38 |
|
39 |
# Start application
|
40 |
+
CMD ["uvicorn", "src.api.api:app", "--host", "0.0.0.0", "--port", "9000", "--reload", "--reload-dir", "/src/api"]
|
|