Update Dockerfile for correct directory structure
Browse files- Dockerfile +52 -38
Dockerfile
CHANGED
@@ -7,7 +7,13 @@ FROM node:20.11-alpine3.19 AS base
|
|
7 |
ENV NODE_OPTIONS="--max_old_space_size=3072" \
|
8 |
NEXT_TELEMETRY_DISABLED=1 \
|
9 |
NODE_ENV=production \
|
10 |
-
PYTHONDONTWRITEBYTECODE=1
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# ============================================
|
13 |
# Web builder stage
|
@@ -16,18 +22,17 @@ FROM base AS web-builder
|
|
16 |
|
17 |
WORKDIR /app/web
|
18 |
|
19 |
-
#
|
20 |
-
COPY
|
21 |
|
22 |
# Install dependencies
|
23 |
-
RUN yarn install --frozen-lockfile --
|
24 |
|
25 |
# Copy web source
|
26 |
-
COPY
|
27 |
|
28 |
-
#
|
29 |
-
RUN yarn
|
30 |
-
yarn build
|
31 |
|
32 |
# ============================================
|
33 |
# Python builder stage
|
@@ -37,20 +42,26 @@ FROM python:3.10-slim-bookworm AS python-builder
|
|
37 |
# Install build dependencies
|
38 |
RUN apt-get update && \
|
39 |
apt-get install -y --no-install-recommends \
|
40 |
-
|
|
|
41 |
&& rm -rf /var/lib/apt/lists/*
|
42 |
|
43 |
WORKDIR /app/api
|
44 |
|
45 |
-
# Install poetry
|
46 |
-
|
|
|
47 |
|
48 |
-
#
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
#
|
52 |
-
|
53 |
-
|
54 |
|
55 |
# ============================================
|
56 |
# Final stage
|
@@ -63,32 +74,34 @@ RUN useradd -m -u 1000 user
|
|
63 |
# Install runtime dependencies
|
64 |
RUN apt-get update && \
|
65 |
apt-get install -y --no-install-recommends \
|
66 |
-
nodejs \
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
&& rm -rf /var/lib/apt/lists/*
|
70 |
|
71 |
-
#
|
72 |
WORKDIR /app
|
73 |
RUN mkdir -p api web && chown -R user:user /app
|
74 |
|
75 |
-
#
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
flask \
|
80 |
-
cloudscraper \
|
81 |
-
transformers
|
82 |
|
83 |
-
#
|
84 |
-
|
85 |
-
COPY --chown=user ./api /app/api/
|
86 |
|
87 |
-
# Copy
|
88 |
-
COPY --
|
|
|
|
|
89 |
COPY --from=web-builder --chown=user /app/web/public /app/web/public
|
90 |
-
COPY --from=web-builder --chown=user /app/web/node_modules /app/web/node_modules
|
91 |
-
COPY --from=web-builder --chown=user /app/web/package.json /app/web/package.json
|
92 |
|
93 |
# Set environment variables
|
94 |
ENV FLASK_APP=app.py \
|
@@ -103,13 +116,14 @@ ENV FLASK_APP=app.py \
|
|
103 |
PATH="/usr/local/bin:${PATH}" \
|
104 |
PYTHONPATH=/app/api \
|
105 |
MAIL_TYPE=resend \
|
106 |
-
MAIL_RESEND_API_KEY=null
|
|
|
107 |
|
108 |
USER user
|
109 |
-
EXPOSE 7860
|
110 |
|
111 |
-
# Copy entrypoint
|
112 |
-
COPY --chown=user
|
113 |
RUN chmod +x /app/entrypoint.sh
|
114 |
|
115 |
WORKDIR /app
|
|
|
7 |
ENV NODE_OPTIONS="--max_old_space_size=3072" \
|
8 |
NEXT_TELEMETRY_DISABLED=1 \
|
9 |
NODE_ENV=production \
|
10 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
11 |
+
TZ=UTC
|
12 |
+
|
13 |
+
# Install base dependencies
|
14 |
+
RUN apk add --no-cache tzdata && \
|
15 |
+
ln -s /usr/share/zoneinfo/${TZ} /etc/localtime && \
|
16 |
+
echo ${TZ} > /etc/timezone
|
17 |
|
18 |
# ============================================
|
19 |
# Web builder stage
|
|
|
22 |
|
23 |
WORKDIR /app/web
|
24 |
|
25 |
+
# Copy package files first
|
26 |
+
COPY web/package.json web/yarn.lock ./
|
27 |
|
28 |
# Install dependencies
|
29 |
+
RUN yarn install --frozen-lockfile --production=false
|
30 |
|
31 |
# Copy web source
|
32 |
+
COPY web/ .
|
33 |
|
34 |
+
# Build with standalone output
|
35 |
+
RUN yarn build
|
|
|
36 |
|
37 |
# ============================================
|
38 |
# Python builder stage
|
|
|
42 |
# Install build dependencies
|
43 |
RUN apt-get update && \
|
44 |
apt-get install -y --no-install-recommends \
|
45 |
+
gcc g++ libc-dev libffi-dev \
|
46 |
+
libgmp-dev libmpfr-dev libmpc-dev \
|
47 |
&& rm -rf /var/lib/apt/lists/*
|
48 |
|
49 |
WORKDIR /app/api
|
50 |
|
51 |
+
# Install poetry with specific version
|
52 |
+
ENV POETRY_VERSION=1.8.3
|
53 |
+
RUN pip install --no-cache-dir poetry==${POETRY_VERSION}
|
54 |
|
55 |
+
# Configure Poetry
|
56 |
+
ENV POETRY_CACHE_DIR=/tmp/poetry_cache \
|
57 |
+
POETRY_NO_INTERACTION=1 \
|
58 |
+
POETRY_VIRTUALENVS_IN_PROJECT=true \
|
59 |
+
POETRY_VIRTUALENVS_CREATE=true \
|
60 |
+
POETRY_REQUESTS_TIMEOUT=15
|
61 |
|
62 |
+
# Copy and install Python dependencies
|
63 |
+
COPY api/pyproject.toml api/poetry.lock ./
|
64 |
+
RUN poetry install --sync --no-cache --no-root
|
65 |
|
66 |
# ============================================
|
67 |
# Final stage
|
|
|
74 |
# Install runtime dependencies
|
75 |
RUN apt-get update && \
|
76 |
apt-get install -y --no-install-recommends \
|
77 |
+
curl nodejs npm libgmp-dev libmpfr-dev libmpc-dev \
|
78 |
+
&& echo "deb http://deb.debian.org/debian testing main" > /etc/apt/sources.list \
|
79 |
+
&& apt-get update \
|
80 |
+
&& apt-get install -y --no-install-recommends \
|
81 |
+
expat=2.6.3-2 libldap-2.5-0=2.5.18+dfsg-3+b1 \
|
82 |
+
perl=5.40.0-6 libsqlite3-0=3.46.1-1 \
|
83 |
+
zlib1g=1:1.3.dfsg+really1.3.1-1+b1 \
|
84 |
+
fonts-noto-cjk \
|
85 |
+
&& apt-get autoremove -y \
|
86 |
&& rm -rf /var/lib/apt/lists/*
|
87 |
|
88 |
+
# Set up directory structure
|
89 |
WORKDIR /app
|
90 |
RUN mkdir -p api web && chown -R user:user /app
|
91 |
|
92 |
+
# Copy Python environment
|
93 |
+
ENV VIRTUAL_ENV=/app/api/.venv
|
94 |
+
COPY --from=python-builder /app/api/.venv ${VIRTUAL_ENV}
|
95 |
+
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
|
|
|
|
|
|
96 |
|
97 |
+
# Download NLTK data
|
98 |
+
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
|
|
|
99 |
|
100 |
+
# Copy application files
|
101 |
+
COPY --chown=user api/ /app/api/
|
102 |
+
COPY --from=web-builder --chown=user /app/web/.next/standalone /app/web
|
103 |
+
COPY --from=web-builder --chown=user /app/web/.next/static /app/web/.next/static
|
104 |
COPY --from=web-builder --chown=user /app/web/public /app/web/public
|
|
|
|
|
105 |
|
106 |
# Set environment variables
|
107 |
ENV FLASK_APP=app.py \
|
|
|
116 |
PATH="/usr/local/bin:${PATH}" \
|
117 |
PYTHONPATH=/app/api \
|
118 |
MAIL_TYPE=resend \
|
119 |
+
MAIL_RESEND_API_KEY=null \
|
120 |
+
TZ=UTC
|
121 |
|
122 |
USER user
|
123 |
+
EXPOSE 7860 3000
|
124 |
|
125 |
+
# Copy and setup entrypoint
|
126 |
+
COPY --chown=user docker/entrypoint.sh /app/entrypoint.sh
|
127 |
RUN chmod +x /app/entrypoint.sh
|
128 |
|
129 |
WORKDIR /app
|