MattiaColucci commited on
Commit
547ce23
·
1 Parent(s): 6451964

docker for hugging spaces (docker spaces)

Browse files
Files changed (3) hide show
  1. README.md +9 -0
  2. docker-compose.yml +2 -2
  3. dockerfile +14 -9
README.md CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  # Syntetic Issue Report Data Generation
2
 
3
  <a target="_blank" href="https://cookiecutter-data-science.drivendata.org/">
 
1
+ ---
2
+ title: Issue report data generation
3
+ emoji: 🚀
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: docker
7
+ app_port: 7860
8
+ ---
9
+
10
  # Syntetic Issue Report Data Generation
11
 
12
  <a target="_blank" href="https://cookiecutter-data-science.drivendata.org/">
docker-compose.yml CHANGED
@@ -3,9 +3,9 @@ services:
3
  # Build the image from the Dockerfile in the current directory
4
  build: .
5
 
6
- # Host the FastAPI application on port 8000
7
  ports:
8
- - "8080:8080"
9
 
10
  secrets:
11
  - dagshub
 
3
  # Build the image from the Dockerfile in the current directory
4
  build: .
5
 
6
+ # Host the FastAPI application on port 7860 (mandatory for hugging face)
7
  ports:
8
+ - "7860:7860"
9
 
10
  secrets:
11
  - dagshub
dockerfile CHANGED
@@ -13,9 +13,15 @@ RUN apt-get update && apt-get install -y \
13
 
14
  COPY --from=ghcr.io/astral-sh/uv:0.9.15 /uv /uvx /bin/
15
 
16
- # Set up a user for the app
17
- RUN useradd appuser
 
 
18
  RUN mkdir -p /app
 
 
 
 
19
 
20
  # 2. IMPOSTAZIONE HOME
21
  # Forziamo la "casa" dell'utente su /app, così tutte le cache finiscono qui
@@ -47,23 +53,22 @@ RUN uv sync --frozen --group docker
47
  # Copy the rest of the project
48
  COPY . .
49
 
 
 
 
 
50
  # Copy the entrypoint script
51
  COPY ./docker/entrypoint.sh /app/entrypoint.sh
52
  RUN chmod +x /app/entrypoint.sh
53
 
54
- # 3. ASSEGNAZIONE PERMESSI FINALE
55
- # Fondamentale: assicuriamo che TUTTO dentro /app sia di proprietà di appuser
56
- # (inclusi i file appena copiati che altrimenti sarebbero di root)
57
- RUN chown -R appuser:appuser /app
58
-
59
  # Switch to the non-root user
60
  USER appuser
61
 
62
  # Expose the port
63
- EXPOSE 8080
64
 
65
  # Set the entrypoint
66
  ENTRYPOINT ["/app/entrypoint.sh"]
67
 
68
  # Run the FastAPI application
69
- CMD ["uvicorn", "syntetic_issue_report_data_generation.api.main:app", "--host", "0.0.0.0", "--port", "8080"]
 
13
 
14
  COPY --from=ghcr.io/astral-sh/uv:0.9.15 /uv /uvx /bin/
15
 
16
+ # set up a user for the app so the container doesn't run as the root user
17
+ # User id miust be 1000 for docker space
18
+ RUN useradd -m -u 1000 appuser
19
+ ENV PATH="/home/appuser/.local/bin:$PATH"
20
  RUN mkdir -p /app
21
+ RUN chown appuser /app
22
+
23
+ # Create a cache directory and set ownership for appuser
24
+ RUN mkdir -p /app/.cache && chown -R appuser:appuser /app/.cache
25
 
26
  # 2. IMPOSTAZIONE HOME
27
  # Forziamo la "casa" dell'utente su /app, così tutte le cache finiscono qui
 
53
  # Copy the rest of the project
54
  COPY . .
55
 
56
+ # Set models ownership
57
+ RUN mkdir -p /app/models
58
+ RUN chown -R appuser:appuser /app/models
59
+
60
  # Copy the entrypoint script
61
  COPY ./docker/entrypoint.sh /app/entrypoint.sh
62
  RUN chmod +x /app/entrypoint.sh
63
 
 
 
 
 
 
64
  # Switch to the non-root user
65
  USER appuser
66
 
67
  # Expose the port
68
+ EXPOSE 7860
69
 
70
  # Set the entrypoint
71
  ENTRYPOINT ["/app/entrypoint.sh"]
72
 
73
  # Run the FastAPI application
74
+ CMD ["uvicorn", "syntetic_issue_report_data_generation.api.main:app", "--host", "0.0.0.0", "--port", "7860"]