Severian commited on
Commit
64cf3a5
1 Parent(s): b2b04b8

Update Dockerfile for correct directory structure

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -28
Dockerfile CHANGED
@@ -10,51 +10,50 @@ ENV NODE_OPTIONS="--max_old_space_size=2048" \
10
  PYTHONDONTWRITEBYTECODE=1 \
11
  TZ=UTC
12
 
 
 
 
 
 
13
  # ============================================
14
  # Web builder stage - optimized
15
  # ============================================
16
  FROM base AS web-builder
17
 
 
 
 
 
 
18
  WORKDIR /app/web
19
 
20
- # Copy only necessary files for build
21
- COPY web/package.json web/yarn.lock ./
22
- COPY web/next.config.js ./
23
- COPY web/postcss.config.js ./
24
- COPY web/tailwind.config.js ./
25
- COPY web/tsconfig.json ./
26
- COPY web/app ./app
27
- COPY web/public ./public
28
-
29
- # Install only production dependencies
30
- RUN yarn config set network-timeout 300000 && \
31
- yarn install --frozen-lockfile --production=true && \
32
  yarn add --dev autoprefixer postcss tailwindcss code-inspector-plugin && \
 
33
  yarn cache clean
34
 
35
- # Build with reduced memory usage
36
- ENV NODE_ENV=production
37
- RUN yarn build
38
-
39
  # ============================================
40
  # Python builder stage - optimized
41
  # ============================================
42
  FROM python:3.10-slim-bookworm AS python-builder
43
 
44
- # Install minimal build dependencies
45
  RUN apt-get update && \
46
  apt-get install -y --no-install-recommends \
47
- gcc libffi-dev && \
48
  rm -rf /var/lib/apt/lists/*
49
 
50
- WORKDIR /app/api
 
 
 
51
 
52
- # Install poetry
53
- RUN pip install --no-cache-dir poetry==1.8.3
54
 
55
- # Install only production dependencies
56
- COPY api/pyproject.toml api/poetry.lock ./
57
- RUN poetry config virtualenvs.create false && \
58
  poetry install --no-dev --no-interaction --no-ansi
59
 
60
  # ============================================
@@ -65,23 +64,36 @@ FROM python:3.10-slim-bookworm
65
  # Create non-root user
66
  RUN useradd -m -u 1000 user
67
 
68
- # Install only essential runtime packages
69
  RUN apt-get update && \
70
  apt-get install -y --no-install-recommends \
71
- nodejs npm curl && \
 
 
 
 
 
 
 
 
72
  rm -rf /var/lib/apt/lists/*
73
 
74
  # Set up directory structure
75
  WORKDIR /app
76
  RUN mkdir -p api web && chown -R user:user /app
77
 
78
- # Copy only necessary files
79
- COPY --from=python-builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
80
  COPY --chown=user api/ /app/api/
 
 
81
  COPY --from=web-builder --chown=user /app/web/.next/standalone /app/web
82
  COPY --from=web-builder --chown=user /app/web/.next/static /app/web/.next/static
83
  COPY --from=web-builder --chown=user /app/web/public /app/web/public
84
 
 
 
 
85
  # Set environment variables
86
  ENV FLASK_APP=app.py \
87
  EDITION=SELF_HOSTED \
 
10
  PYTHONDONTWRITEBYTECODE=1 \
11
  TZ=UTC
12
 
13
+ # Install base dependencies
14
+ RUN apk add --no-cache tzdata && \
15
+ ln -s /usr/share/zoneinfo/UTC /etc/localtime && \
16
+ echo UTC > /etc/timezone
17
+
18
  # ============================================
19
  # Web builder stage - optimized
20
  # ============================================
21
  FROM base AS web-builder
22
 
23
+ WORKDIR /app
24
+
25
+ # Copy entire web directory first
26
+ COPY web/ web/
27
+
28
  WORKDIR /app/web
29
 
30
+ # Install dependencies and build
31
+ RUN yarn install --frozen-lockfile && \
 
 
 
 
 
 
 
 
 
 
32
  yarn add --dev autoprefixer postcss tailwindcss code-inspector-plugin && \
33
+ yarn build && \
34
  yarn cache clean
35
 
 
 
 
 
36
  # ============================================
37
  # Python builder stage - optimized
38
  # ============================================
39
  FROM python:3.10-slim-bookworm AS python-builder
40
 
41
+ # Install build dependencies
42
  RUN apt-get update && \
43
  apt-get install -y --no-install-recommends \
44
+ gcc g++ libc-dev libffi-dev && \
45
  rm -rf /var/lib/apt/lists/*
46
 
47
+ WORKDIR /app
48
+
49
+ # Copy entire api directory
50
+ COPY api/ api/
51
 
52
+ WORKDIR /app/api
 
53
 
54
+ # Install poetry and dependencies
55
+ RUN pip install --no-cache-dir poetry==1.8.3 && \
56
+ poetry config virtualenvs.create false && \
57
  poetry install --no-dev --no-interaction --no-ansi
58
 
59
  # ============================================
 
64
  # Create non-root user
65
  RUN useradd -m -u 1000 user
66
 
67
+ # Install runtime dependencies
68
  RUN apt-get update && \
69
  apt-get install -y --no-install-recommends \
70
+ nodejs npm curl libgmp-dev libmpfr-dev libmpc-dev && \
71
+ echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list && \
72
+ apt-get update && \
73
+ apt-get install -y --no-install-recommends \
74
+ expat=2.6.3-2 libldap-2.5-0=2.5.18+dfsg-3+b1 \
75
+ perl=5.40.0-6 libsqlite3-0=3.46.1-1 \
76
+ zlib1g=1:1.3.dfsg+really1.3.1-1+b1 \
77
+ fonts-noto-cjk && \
78
+ apt-get autoremove -y && \
79
  rm -rf /var/lib/apt/lists/*
80
 
81
  # Set up directory structure
82
  WORKDIR /app
83
  RUN mkdir -p api web && chown -R user:user /app
84
 
85
+ # Copy Python environment and files
86
+ COPY --from=python-builder --chown=user /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
87
  COPY --chown=user api/ /app/api/
88
+
89
+ # Copy Next.js files
90
  COPY --from=web-builder --chown=user /app/web/.next/standalone /app/web
91
  COPY --from=web-builder --chown=user /app/web/.next/static /app/web/.next/static
92
  COPY --from=web-builder --chown=user /app/web/public /app/web/public
93
 
94
+ # Download NLTK data
95
+ RUN python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
96
+
97
  # Set environment variables
98
  ENV FLASK_APP=app.py \
99
  EDITION=SELF_HOSTED \