val2e commited on
Commit
a2f3747
·
verified ·
1 Parent(s): ccdfb0f

Rename Dockerfile-api to Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile-api → Dockerfile +38 -22
Dockerfile-api → Dockerfile RENAMED
@@ -1,23 +1,39 @@
1
- FROM python:3.11.9-slim
2
-
3
- # Copy requirements file
4
- COPY requirements_docker_api.txt .
5
-
6
- # Update pip
7
- RUN pip --timeout=30000 install --no-cache-dir --upgrade pip
8
-
9
- # Install dependecies
10
- RUN pip --timeout=30000 install --no-cache-dir -r requirements_docker_api.txt
11
-
12
- # Copy API
13
- RUN mkdir /src/
14
- COPY ./src /src
15
-
16
- # Set workdir
17
- WORKDIR /
18
-
19
- # Expose app port
20
- EXPOSE 9000
21
-
22
- # Start application
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  CMD ["uvicorn", "src.api.api:app", "--host", "0.0.0.0", "--port", "9000"]
 
1
+ FROM python:3.11.9-slim
2
+
3
+ # Expose the secret SECRETS at build-time
4
+ RUN --mount=type=secret,id=REDIS_URL,mode=0444,required=true
5
+ RUN --mount=type=secret,id=REDIS_USERNAME,mode=0444,required=true
6
+ RUN --mount=type=secret,id=REDIS_PASSWORD,mode=0444,required=true
7
+
8
+ # Read secrets and set environment variables
9
+ RUN export REDIS_URL=$(cat /run/secrets/REDIS_URL) \
10
+ && export REDIS_USERNAME=$(cat /run/secrets/REDIS_USERNAME) \
11
+ && export REDIS_PASSWORD=$(cat /run/secrets/REDIS_PASSWORD) \
12
+ && echo "REDIS_URL=$REDIS_URL" >> /etc/environment \
13
+ && echo "REDIS_USERNAME=$REDIS_USERNAME" >> /etc/environment \
14
+ && echo "REDIS_PASSWORD=$REDIS_PASSWORD" >> /etc/environment
15
+
16
+ # Source the environment file
17
+ RUN . /etc/environment
18
+
19
+ # Copy requirements file
20
+ COPY requirements_docker_api.txt .
21
+
22
+ # Update pip
23
+ RUN pip --timeout=30000 install --no-cache-dir --upgrade pip
24
+
25
+ # Install dependecies
26
+ RUN pip --timeout=30000 install --no-cache-dir -r requirements_docker_api.txt
27
+
28
+ # Copy API
29
+ RUN mkdir /src/
30
+ COPY ./src /src
31
+
32
+ # Set workdir
33
+ WORKDIR /
34
+
35
+ # Expose app port
36
+ EXPOSE 9000
37
+
38
+ # Start application
39
  CMD ["uvicorn", "src.api.api:app", "--host", "0.0.0.0", "--port", "9000"]