avfranco commited on
Commit
fca82fd
·
1 Parent(s): ce6f1e4

ea4all-docker-demo-secrets

Browse files
Files changed (3) hide show
  1. Dockerfile +33 -0
  2. main.py +14 -0
  3. requirements.txt +1 -0
Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11.3
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ # Get secret EXAMPLE and output it to /test at buildtime
10
+ RUN --mount=type=secret,id=EXAMPLE,mode=0444,required=true \
11
+ cat /run/secrets/EXAMPLE > /test
12
+
13
+ # Get secret SECRET_EXAMPLE and clone it as repo at buildtime
14
+ RUN --mount=type=secret,id=SECRET_EXAMPLE,mode=0444,required=true \
15
+ git clone $(cat /run/secrets/SECRET_EXAMPLE)
16
+
17
+ # Set up a new user named "user" with user ID 1000
18
+ RUN useradd -m -u 1000 user
19
+
20
+ # Switch to the "user" user
21
+ USER user
22
+
23
+ # Set home to the user's home directory
24
+ ENV HOME=/home/user \
25
+ PATH=/home/user/.local/bin:$PATH
26
+
27
+ # Set the working directory to the user's home directory
28
+ WORKDIR $HOME/app
29
+
30
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
31
+ COPY --chown=user . $HOME/app
32
+
33
+ CMD ["python", "main.py"]
main.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import gradio as gr
3
+ import os
4
+
5
+
6
+ def random_response(message, history):
7
+ return random.choice(["Yes", "No"])
8
+
9
+ def run():
10
+ demo = gr.ChatInterface(random_response, title=os.environ.get("EXAMPLE"), description=os.environ.get("SECRET_EXAMPLE"))
11
+ demo.launch(server_name="0.0.0.0", server_port=7860)
12
+
13
+ if __name__ == "__main__":
14
+ run()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio==4.18.0