Severian commited on
Commit
6516462
·
verified ·
1 Parent(s): f998768

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -37
Dockerfile CHANGED
@@ -1,58 +1,36 @@
1
  # Base Python image with correct version
2
  FROM python:3.12-slim-bookworm AS base
3
 
4
- # Set shared environment variables
5
- ENV NODE_VERSION=20.11.0 \
6
- NODE_OPTIONS="--max_old_space_size=2048" \
7
- NEXT_TELEMETRY_DISABLED=1 \
8
- NODE_ENV=production \
9
- PYTHONDONTWRITEBYTECODE=1 \
10
- POETRY_VERSION=1.8.4 \
11
  POETRY_NO_INTERACTION=1 \
12
  POETRY_VIRTUALENVS_CREATE=true \
13
  POETRY_VIRTUALENVS_IN_PROJECT=true \
14
- POETRY_CACHE_DIR=/tmp/poetry_cache
 
15
 
16
  # Install system dependencies
17
- RUN apt-get update && apt-get install -y \
18
- curl \
19
- git \
20
- gcc \
21
- python3-dev \
22
- libgmp-dev \
23
- libmpfr-dev \
24
- libmpc-dev \
25
- && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
26
- && apt-get install -y nodejs \
27
- && npm install -g npm@latest \
28
- && rm -rf /var/lib/apt/lists/* \
29
- && pip install --no-cache-dir "poetry==${POETRY_VERSION}"
30
-
31
- # Pull official images
32
- FROM langgenius/dify-web:latest AS web
33
- FROM langgenius/dify-api:latest AS api
34
 
35
- # Final stage
36
- FROM base
37
-
38
- # Create non-root user (required by Hugging Face)
39
  RUN useradd -m -u 1000 user
40
 
41
- # Set up directory structure and persistent storage
42
  WORKDIR /app
43
  RUN mkdir -p api web /data/storage && \
44
  chown -R user:user /app /data
45
 
46
- # Copy from official images instead of building
47
- COPY --from=web --chown=user /app/web /app/web/
48
- COPY --from=api --chown=user /app/api /app/api/
49
-
50
- # Copy Poetry files
51
- COPY --chown=user pyproject.toml poetry.lock poetry.toml ./api/
52
 
53
  # Install dependencies
54
  WORKDIR /app/api
55
- RUN poetry install --no-root --no-dev
56
 
57
  # Copy application code
58
  COPY --chown=user . .
 
1
  # Base Python image with correct version
2
  FROM python:3.12-slim-bookworm AS base
3
 
4
+ WORKDIR /app/api
5
+
6
+ # Install Poetry and configure
7
+ ENV POETRY_VERSION=1.8.4 \
 
 
 
8
  POETRY_NO_INTERACTION=1 \
9
  POETRY_VIRTUALENVS_CREATE=true \
10
  POETRY_VIRTUALENVS_IN_PROJECT=true \
11
+ POETRY_CACHE_DIR=/tmp/poetry_cache \
12
+ POETRY_REQUESTS_TIMEOUT=15
13
 
14
  # Install system dependencies
15
+ RUN apt-get update && apt-get install -y --no-install-recommends \
16
+ gcc g++ libc-dev libffi-dev libgmp-dev libmpfr-dev libmpc-dev \
17
+ && pip install --no-cache-dir "poetry==${POETRY_VERSION}" \
18
+ && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ # Create non-root user
 
 
 
21
  RUN useradd -m -u 1000 user
22
 
23
+ # Set up directory structure
24
  WORKDIR /app
25
  RUN mkdir -p api web /data/storage && \
26
  chown -R user:user /app /data
27
 
28
+ # Copy Poetry configuration files
29
+ COPY --chown=user api/pyproject.toml api/poetry.lock api/poetry.toml ./api/
 
 
 
 
30
 
31
  # Install dependencies
32
  WORKDIR /app/api
33
+ RUN poetry install --no-root --no-dev --no-cache
34
 
35
  # Copy application code
36
  COPY --chown=user . .