Technologic101 commited on
Commit
c7c5f29
·
1 Parent(s): e9103fb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -11
Dockerfile CHANGED
@@ -1,34 +1,43 @@
1
  # Use Python 3.11 slim image
2
  FROM biggates/poetry:2.0.1-py3.11-slim
3
 
 
4
  RUN apt-get update && apt-get install -y \
5
  curl \
6
  build-essential \
7
  && rm -rf /var/lib/apt/lists/*
8
 
 
 
 
 
9
  RUN useradd -m -u 1000 user
10
- USER user
11
- ENV PATH="/home/user/.local/bin:$PATH"
12
 
13
- # Install Poetry
14
- RUN pip install poetry
 
 
 
15
 
 
 
16
  WORKDIR /app
17
 
18
- # Copy dependency files
 
 
 
 
 
19
  COPY --chown=user pyproject.toml poetry.lock* ./
20
 
21
- # Install dependencies using Poetry
22
  RUN poetry config virtualenvs.create false \
23
- && poetry install --no-interaction --no-ansi
24
 
25
  # Copy application code
26
  COPY --chown=user . .
27
 
28
- # Set environment variables for HuggingFace Spaces
29
- ENV PYTHONPATH=/app
30
- ENV PORT=7860
31
-
32
  # Expose the port Chainlit runs on
33
  EXPOSE 7860
34
 
 
1
  # Use Python 3.11 slim image
2
  FROM biggates/poetry:2.0.1-py3.11-slim
3
 
4
+ # Run system updates and installations as root
5
  RUN apt-get update && apt-get install -y \
6
  curl \
7
  build-essential \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Create app directory with correct permissions
11
+ RUN mkdir /app && chown -R 1000:1000 /app
12
+
13
+ # Create non-root user
14
  RUN useradd -m -u 1000 user
 
 
15
 
16
+ # Set up Poetry environment as root
17
+ ENV POETRY_HOME=/opt/poetry
18
+ ENV POETRY_VERSION=1.7.1
19
+ RUN curl -sSL https://install.python-poetry.org | python - \
20
+ && ln -s /opt/poetry/bin/poetry /usr/local/bin/poetry
21
 
22
+ # Switch to non-root user
23
+ USER user
24
  WORKDIR /app
25
 
26
+ # Set up Python path
27
+ ENV PATH="/home/user/.local/bin:$PATH"
28
+ ENV PYTHONPATH=/app
29
+ ENV PORT=7860
30
+
31
+ # Copy dependency files with correct ownership
32
  COPY --chown=user pyproject.toml poetry.lock* ./
33
 
34
+ # Install dependencies in user space
35
  RUN poetry config virtualenvs.create false \
36
+ && poetry install --no-root --no-interaction --no-ansi
37
 
38
  # Copy application code
39
  COPY --chown=user . .
40
 
 
 
 
 
41
  # Expose the port Chainlit runs on
42
  EXPOSE 7860
43