Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +40 -8
Dockerfile
CHANGED
@@ -1,18 +1,24 @@
|
|
|
|
1 |
FROM node:lts-alpine AS frontend-builder
|
2 |
|
3 |
WORKDIR /app/frontend
|
4 |
|
|
|
5 |
RUN npm install -g pnpm
|
6 |
|
|
|
7 |
COPY frontend/package.json frontend/pnpm-lock.yaml ./
|
8 |
|
|
|
9 |
RUN pnpm install --frozen-lockfile
|
10 |
|
|
|
11 |
COPY frontend/ ./
|
12 |
|
|
|
13 |
RUN pnpm build
|
14 |
|
15 |
-
# Final
|
16 |
FROM python:3.10-slim AS final
|
17 |
|
18 |
WORKDIR /app
|
@@ -24,25 +30,51 @@ RUN apt-get update && \
|
|
24 |
update-ca-certificates && \
|
25 |
rm -rf /var/lib/apt/lists/*
|
26 |
|
|
|
27 |
COPY requirements.txt ./
|
28 |
RUN pip install --no-cache-dir --upgrade pip && \
|
29 |
pip install --no-cache-dir -r requirements.txt
|
30 |
|
|
|
31 |
RUN mkdir account
|
32 |
-
|
33 |
RUN mkdir -p templates static
|
34 |
|
|
|
35 |
COPY run.py ./
|
36 |
COPY utils/ ./utils/
|
37 |
|
|
|
38 |
COPY --from=frontend-builder /app/frontend/dist/index.html ./templates/
|
39 |
COPY --from=frontend-builder /app/frontend/dist/* ./static/
|
40 |
|
|
|
41 |
EXPOSE 5000
|
42 |
|
43 |
-
#
|
44 |
-
#
|
45 |
-
#
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Stage 1: Build the frontend
|
2 |
FROM node:lts-alpine AS frontend-builder
|
3 |
|
4 |
WORKDIR /app/frontend
|
5 |
|
6 |
+
# Install pnpm globally
|
7 |
RUN npm install -g pnpm
|
8 |
|
9 |
+
# Copy package.json and pnpm-lock.yaml first to leverage Docker cache
|
10 |
COPY frontend/package.json frontend/pnpm-lock.yaml ./
|
11 |
|
12 |
+
# Install dependencies using pnpm
|
13 |
RUN pnpm install --frozen-lockfile
|
14 |
|
15 |
+
# Copy the rest of the frontend source code
|
16 |
COPY frontend/ ./
|
17 |
|
18 |
+
# Build the frontend
|
19 |
RUN pnpm build
|
20 |
|
21 |
+
# Stage 2: Final Python application image
|
22 |
FROM python:3.10-slim AS final
|
23 |
|
24 |
WORKDIR /app
|
|
|
30 |
update-ca-certificates && \
|
31 |
rm -rf /var/lib/apt/lists/*
|
32 |
|
33 |
+
# Copy requirements.txt and install Python dependencies
|
34 |
COPY requirements.txt ./
|
35 |
RUN pip install --no-cache-dir --upgrade pip && \
|
36 |
pip install --no-cache-dir -r requirements.txt
|
37 |
|
38 |
+
# Create necessary directories
|
39 |
RUN mkdir account
|
|
|
40 |
RUN mkdir -p templates static
|
41 |
|
42 |
+
# Copy application code and utils
|
43 |
COPY run.py ./
|
44 |
COPY utils/ ./utils/
|
45 |
|
46 |
+
# Copy built frontend assets from the builder stage
|
47 |
COPY --from=frontend-builder /app/frontend/dist/index.html ./templates/
|
48 |
COPY --from=frontend-builder /app/frontend/dist/* ./static/
|
49 |
|
50 |
+
# Expose the port the app runs on
|
51 |
EXPOSE 5000
|
52 |
|
53 |
+
# --- TEMPORARY DIAGNOSTIC CMD ---
|
54 |
+
# This CMD will run diagnostic commands before starting the Python application.
|
55 |
+
# Their output will appear in the Hugging Face container logs.
|
56 |
+
# REMEMBER TO REVERT THIS to CMD ["python", "run.py"] after diagnostics.
|
57 |
+
CMD sh -c "\
|
58 |
+
echo '======================================================================'; \
|
59 |
+
echo '=== DIAGNOSTIC STEP 1: Testing msoauth2api.233285.xyz with curl ==='; \
|
60 |
+
echo '======================================================================'; \
|
61 |
+
curl -vvv --max-time 30 https://msoauth2api.233285.xyz/api/mail-new; \
|
62 |
+
echo; \
|
63 |
+
echo '======================================================================'; \
|
64 |
+
echo '=== DIAGNOSTIC STEP 2: Testing SSL/TLS connection with openssl ==='; \
|
65 |
+
echo '======================================================================'; \
|
66 |
+
echo | openssl s_client -connect msoauth2api.233285.xyz:443 -servername msoauth2api.233285.xyz -showcerts -msg 2>/dev/null; \
|
67 |
+
echo; \
|
68 |
+
echo '======================================================================'; \
|
69 |
+
echo '=== DIAGNOSTIC STEP 3: Testing DNS resolution for the host ==='; \
|
70 |
+
echo '======================================================================'; \
|
71 |
+
getent hosts msoauth2api.233285.xyz; \
|
72 |
+
echo; \
|
73 |
+
echo '======================================================================'; \
|
74 |
+
echo '=== DIAGNOSTICS COMPLETE - Starting Python application ==='; \
|
75 |
+
echo '======================================================================'; \
|
76 |
+
python run.py"
|
77 |
+
|
78 |
+
# --- ORIGINAL CMD ---
|
79 |
+
# After diagnostics, comment out the CMD above and uncomment the line below:
|
80 |
+
# CMD ["python", "run.py"]
|