klasocki commited on
Commit
2a30eb1
1 Parent(s): ca2592c

Add user to dockerfile for the huggingface hub

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -13
Dockerfile CHANGED
@@ -1,22 +1,28 @@
1
  FROM python:3.10-slim as base
2
 
3
- WORKDIR /comma-fixer
 
 
 
 
 
 
 
4
  ENV PYTHONUNBUFFERED=1
5
 
6
- RUN python -m venv /venv
7
- ENV PATH="/venv/bin:$PATH"
8
 
9
- COPY setup.py .
10
  RUN pip install --upgrade pip
11
  RUN pip install --no-cache-dir --upgrade .
12
 
13
  # This pre-downloads models and tokenizers
14
- COPY commafixer/src/ commafixer/src/
15
- ENV TRANSFORMERS_CACHE=/coma-fixer/.cache
16
  RUN python commafixer/src/baseline.py
17
  RUN python commafixer/src/fixer.py
18
 
19
- COPY . .
20
 
21
  FROM base as test
22
 
@@ -25,13 +31,18 @@ RUN python -m pytest tests
25
 
26
  FROM python:3.10-slim as deploy
27
 
28
- WORKDIR /comma-fixer
29
- COPY --from=base /comma-fixer /comma-fixer
30
- COPY --from=base /venv /venv
31
- ENV PATH="/venv/bin:$PATH"
 
 
 
 
 
 
32
  # Copy pre-downloaded models and make sure we are using the env
33
- ENV TRANSFORMERS_CACHE=/coma-fixer/.cache
34
- COPY --from=base /coma-fixer/.cache /coma-fixer/.cache
35
 
36
  EXPOSE 8000
37
  CMD uvicorn "app:app" --port 8000 --host "0.0.0.0"
 
1
  FROM python:3.10-slim as base
2
 
3
+ # Set up the user for huggingface hub, avoids permission issues
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
+ ENV HOME=/home/user \
7
+ PATH=/home/user/.local/bin:$PATH
8
+
9
+ WORKDIR $HOME/comma-fixer
10
+
11
  ENV PYTHONUNBUFFERED=1
12
 
13
+ RUN python -m venv venv
14
+ ENV PATH="$HOME/comma-fixer/venv/bin:$PATH"
15
 
16
+ COPY --chown=user setup.py .
17
  RUN pip install --upgrade pip
18
  RUN pip install --no-cache-dir --upgrade .
19
 
20
  # This pre-downloads models and tokenizers
21
+ COPY --chown=user commafixer/src/ commafixer/src/
 
22
  RUN python commafixer/src/baseline.py
23
  RUN python commafixer/src/fixer.py
24
 
25
+ COPY --chown=user . .
26
 
27
  FROM base as test
28
 
 
31
 
32
  FROM python:3.10-slim as deploy
33
 
34
+ RUN useradd -m -u 1000 user
35
+ USER user
36
+ ENV HOME=/home/user \
37
+ PATH=/home/user/.local/bin:$PATH
38
+
39
+ WORKDIR $HOME/comma-fixer
40
+
41
+ COPY --chown=user --from=base $HOME/comma-fixer $HOME/comma-fixer
42
+ COPY --chown=user --from=base $HOME/comma-fixer/venv $HOME/comma-fixer/venv
43
+ ENV PATH="$HOME/comma-fixer/venv/bin:$PATH"
44
  # Copy pre-downloaded models and make sure we are using the env
45
+ COPY --chown=user --from=base $HOME/.cache/huggingface $HOME/.cache/huggingface
 
46
 
47
  EXPOSE 8000
48
  CMD uvicorn "app:app" --port 8000 --host "0.0.0.0"