Martinacap02 commited on
Commit
7eb37a1
·
1 Parent(s): 3440013

Fix Dockerfile: run apt-get as root and install uv as user

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -7
Dockerfile CHANGED
@@ -5,23 +5,28 @@ ENV PYTHONDONTWRITEBYTECODE=1
5
  ENV PIP_NO_CACHE_DIR=1
6
  ENV PIP_DISABLE_PIP_VERSION_CHECK=1
7
 
 
 
 
 
 
 
8
  RUN useradd -m -u 1000 user
 
 
9
  USER user
10
  ENV PATH="/home/user/.local/bin:$PATH"
11
 
12
  WORKDIR /cardioTrack
13
 
14
- RUN apt-get update && apt-get install -y --no-install-recommends \
15
- curl ca-certificates \
16
- && rm -rf /var/lib/apt/lists/*
17
-
18
  RUN curl -LsSf https://astral.sh/uv/install.sh | sh
19
- #ENV PATH="/root/.local/bin:$PATH"
20
-
21
- COPY --chown=user pyproject.toml uv.lock ./
22
 
 
 
23
  RUN uv sync --locked --no-install-project
24
 
 
25
  COPY --chown=user predicting_outcomes_in_heart_failure ./predicting_outcomes_in_heart_failure
26
  COPY --chown=user models/nosex/random_forest.joblib ./models/nosex/random_forest.joblib
27
  COPY --chown=user reports/nosex/random_forest/cv_parameters.json ./reports/nosex/random_forest/cv_parameters.json
@@ -29,6 +34,7 @@ COPY --chown=user data/interim/preprocess_artifacts/scaler.joblib ./data/interim
29
  COPY --chown=user metrics/test/nosex/random_forest.json ./metrics/test/nosex/random_forest.json
30
  COPY --chown=user README.md ./README.md
31
 
 
32
  EXPOSE 7860
33
 
34
  CMD ["uv", "run", "uvicorn", "predicting_outcomes_in_heart_failure.app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
5
  ENV PIP_NO_CACHE_DIR=1
6
  ENV PIP_DISABLE_PIP_VERSION_CHECK=1
7
 
8
+ # 1) Installo pacchetti di sistema COME ROOT
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ curl ca-certificates \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # 2) Creo l'utente non-root
14
  RUN useradd -m -u 1000 user
15
+
16
+ # 3) Passo all'utente non-root
17
  USER user
18
  ENV PATH="/home/user/.local/bin:$PATH"
19
 
20
  WORKDIR /cardioTrack
21
 
22
+ # 4) Installo uv come user (finisce in /home/user/.local/bin)
 
 
 
23
  RUN curl -LsSf https://astral.sh/uv/install.sh | sh
 
 
 
24
 
25
+ # 5) Copio i file di progetto e faccio uv sync
26
+ COPY --chown=user pyproject.toml uv.lock ./
27
  RUN uv sync --locked --no-install-project
28
 
29
+ # 6) Copio il resto dei file necessari all'inferenza
30
  COPY --chown=user predicting_outcomes_in_heart_failure ./predicting_outcomes_in_heart_failure
31
  COPY --chown=user models/nosex/random_forest.joblib ./models/nosex/random_forest.joblib
32
  COPY --chown=user reports/nosex/random_forest/cv_parameters.json ./reports/nosex/random_forest/cv_parameters.json
 
34
  COPY --chown=user metrics/test/nosex/random_forest.json ./metrics/test/nosex/random_forest.json
35
  COPY --chown=user README.md ./README.md
36
 
37
+ # EXPOSE non è necessario per HF, ma non dà fastidio
38
  EXPOSE 7860
39
 
40
  CMD ["uv", "run", "uvicorn", "predicting_outcomes_in_heart_failure.app.main:app", "--host", "0.0.0.0", "--port", "7860"]