Update Dockerfile for correct directory structure
Browse files- Dockerfile +17 -28
Dockerfile
CHANGED
@@ -28,11 +28,6 @@ RUN yarn install --frozen-lockfile --network-timeout 300000 && \
|
|
28 |
# Copy source files
|
29 |
COPY web/ .
|
30 |
|
31 |
-
# Create a minimal next.config.js if needed
|
32 |
-
RUN if [ ! -f next.config.js ]; then \
|
33 |
-
echo "module.exports = { reactStrictMode: true };" > next.config.js; \
|
34 |
-
fi
|
35 |
-
|
36 |
# Build the application with standalone output
|
37 |
RUN NODE_PATH=/usr/local/lib/node_modules yarn build
|
38 |
|
@@ -68,29 +63,22 @@ RUN apt-get update && \
|
|
68 |
npm \
|
69 |
&& rm -rf /var/lib/apt/lists/*
|
70 |
|
71 |
-
#
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
# Create necessary directories with correct permissions
|
76 |
-
RUN mkdir -p /home/user/app/api /home/user/app/web && \
|
77 |
-
chown -R user:user /home/user/app
|
78 |
-
|
79 |
-
# Set the working directory
|
80 |
-
WORKDIR /home/user/app
|
81 |
-
|
82 |
-
# Install gunicorn
|
83 |
-
RUN pip install --no-cache-dir gunicorn gevent
|
84 |
|
85 |
# Copy Python environment and set permissions
|
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/ /
|
88 |
|
89 |
# Copy web build artifacts with correct permissions
|
90 |
-
COPY --from=web-builder --chown=user /app/web/.next /
|
91 |
-
COPY --from=web-builder --chown=user /app/web/public /
|
92 |
-
COPY --from=web-builder --chown=user /app/web/node_modules /
|
93 |
-
COPY --from=web-builder --chown=user /app/web/package.json /
|
|
|
|
|
|
|
94 |
|
95 |
# Set environment variables
|
96 |
ENV FLASK_APP=app.py \
|
@@ -100,18 +88,19 @@ ENV FLASK_APP=app.py \
|
|
100 |
CONSOLE_WEB_URL=http://127.0.0.1:3000 \
|
101 |
SERVICE_API_URL=http://127.0.0.1:7860 \
|
102 |
APP_WEB_URL=http://127.0.0.1:3000 \
|
103 |
-
NODE_ENV=production
|
|
|
104 |
|
105 |
# Switch to the non-root user
|
106 |
USER user
|
107 |
|
108 |
# Expose port 7860 as required by Hugging Face Spaces
|
109 |
-
EXPOSE 7860
|
110 |
|
111 |
# Setup entrypoint
|
112 |
-
COPY --chown=user docker/entrypoint.sh /
|
113 |
-
RUN chmod +x /
|
114 |
|
115 |
-
WORKDIR /
|
116 |
|
117 |
CMD ["./entrypoint.sh"]
|
|
|
28 |
# Copy source files
|
29 |
COPY web/ .
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
# Build the application with standalone output
|
32 |
RUN NODE_PATH=/usr/local/lib/node_modules yarn build
|
33 |
|
|
|
63 |
npm \
|
64 |
&& rm -rf /var/lib/apt/lists/*
|
65 |
|
66 |
+
# Create app directory structure
|
67 |
+
WORKDIR /app
|
68 |
+
RUN mkdir -p api web && chown -R user:user /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
# Copy Python environment and set permissions
|
71 |
COPY --from=python-builder --chown=user /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
72 |
+
COPY --chown=user api/ /app/api/
|
73 |
|
74 |
# Copy web build artifacts with correct permissions
|
75 |
+
COPY --from=web-builder --chown=user /app/web/.next /app/web/.next
|
76 |
+
COPY --from=web-builder --chown=user /app/web/public /app/web/public
|
77 |
+
COPY --from=web-builder --chown=user /app/web/node_modules /app/web/node_modules
|
78 |
+
COPY --from=web-builder --chown=user /app/web/package.json /app/web/package.json
|
79 |
+
|
80 |
+
# Install gunicorn
|
81 |
+
RUN pip install --no-cache-dir gunicorn gevent
|
82 |
|
83 |
# Set environment variables
|
84 |
ENV FLASK_APP=app.py \
|
|
|
88 |
CONSOLE_WEB_URL=http://127.0.0.1:3000 \
|
89 |
SERVICE_API_URL=http://127.0.0.1:7860 \
|
90 |
APP_WEB_URL=http://127.0.0.1:3000 \
|
91 |
+
NODE_ENV=production \
|
92 |
+
HOME=/app
|
93 |
|
94 |
# Switch to the non-root user
|
95 |
USER user
|
96 |
|
97 |
# Expose port 7860 as required by Hugging Face Spaces
|
98 |
+
EXPOSE 7860 3000
|
99 |
|
100 |
# Setup entrypoint
|
101 |
+
COPY --chown=user docker/entrypoint.sh /app/entrypoint.sh
|
102 |
+
RUN chmod +x /app/entrypoint.sh
|
103 |
|
104 |
+
WORKDIR /app
|
105 |
|
106 |
CMD ["./entrypoint.sh"]
|