Robys01 commited on
Commit
634d3ae
Β·
1 Parent(s): 0fd4d4e

Add Dockerfile for containerization

Browse files
Files changed (3) hide show
  1. Dockerfile +33 -0
  2. README.md +2 -1
  3. app.py +1 -1
Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stage 1: Builder
2
+ FROM python:3.12-slim AS builder
3
+
4
+ WORKDIR /app
5
+
6
+ # Install system build dependencies
7
+ RUN apt-get update && apt-get install -y cmake g++ make build-essential && rm -rf /var/lib/apt/lists/*
8
+
9
+ RUN python -m venv venv
10
+ ENV VIRTUAL_ENV=/app/venv
11
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
12
+
13
+ COPY requirements.txt .
14
+
15
+ RUN pip install --no-cache-dir -r requirements.txt
16
+
17
+ RUN useradd -m -u 1000 user
18
+
19
+ USER user
20
+
21
+ # Set home to the user's home directory
22
+ ENV HOME=/home/user \
23
+ PATH=/home/user/.local/bin:$PATH
24
+
25
+ # Set the working directory to the user's home directory
26
+ WORKDIR $HOME/app
27
+
28
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
29
+ COPY --chown=user . $HOME/app
30
+
31
+ EXPOSE 7860
32
+
33
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -3,10 +3,11 @@ title: Face Aging
3
  emoji: πŸ‘
4
  colorFrom: blue
5
  colorTo: purple
6
- sdk: gradio
7
  sdk_version: 5.15.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
3
  emoji: πŸ‘
4
  colorFrom: blue
5
  colorTo: purple
6
+ sdk: docker
7
  sdk_version: 5.15.0
8
  app_file: app.py
9
  pinned: false
10
+ license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -36,4 +36,4 @@ iface = gr.Interface(
36
  )
37
 
38
  if __name__ == "__main__":
39
- iface.launch()
 
36
  )
37
 
38
  if __name__ == "__main__":
39
+ iface.launch(server_name="0.0.0.0", server_port=7860)