Spaces:
Build error
Build error
Commit
·
cd3b571
1
Parent(s):
8d1fed3
update
Browse files- .dockerignore +60 -0
- .vscode/settings.json +2 -0
- Dockerfile +57 -51
- scripts/build_frontend.sh +0 -8
- scripts/start.sh +0 -7
.dockerignore
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Git
|
2 |
+
.git
|
3 |
+
.gitignore
|
4 |
+
|
5 |
+
# Node modules
|
6 |
+
node_modules
|
7 |
+
npm-debug.log*
|
8 |
+
yarn-debug.log*
|
9 |
+
yarn-error.log*
|
10 |
+
|
11 |
+
# Next.js
|
12 |
+
.next/
|
13 |
+
out/
|
14 |
+
build/
|
15 |
+
|
16 |
+
# Python
|
17 |
+
__pycache__/
|
18 |
+
*.py[cod]
|
19 |
+
*$py.class
|
20 |
+
*.so
|
21 |
+
.Python
|
22 |
+
env/
|
23 |
+
venv/
|
24 |
+
.venv/
|
25 |
+
pip-log.txt
|
26 |
+
pip-delete-this-directory.txt
|
27 |
+
|
28 |
+
# IDE
|
29 |
+
.vscode/
|
30 |
+
.idea/
|
31 |
+
*.swp
|
32 |
+
*.swo
|
33 |
+
|
34 |
+
# OS
|
35 |
+
.DS_Store
|
36 |
+
Thumbs.db
|
37 |
+
|
38 |
+
# Logs
|
39 |
+
*.log
|
40 |
+
|
41 |
+
# Environment files (will be copied explicitly)
|
42 |
+
.env*
|
43 |
+
!.env.example
|
44 |
+
|
45 |
+
# Cache
|
46 |
+
.cache/
|
47 |
+
.npm/
|
48 |
+
.eslintcache
|
49 |
+
|
50 |
+
# Coverage
|
51 |
+
coverage/
|
52 |
+
.nyc_output/
|
53 |
+
|
54 |
+
# Documentation
|
55 |
+
*.md
|
56 |
+
!README.md
|
57 |
+
|
58 |
+
# Temporary files
|
59 |
+
*.tmp
|
60 |
+
*.temp
|
.vscode/settings.json
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
}
|
Dockerfile
CHANGED
@@ -1,63 +1,69 @@
|
|
1 |
-
# Multi-stage
|
|
|
2 |
|
3 |
-
#
|
4 |
-
FROM node:20-bullseye AS frontend-builder
|
5 |
WORKDIR /app/frontend
|
6 |
-
ENV NEXT_TELEMETRY_DISABLED=1
|
7 |
|
8 |
-
# Copy
|
9 |
-
COPY metsa-frontend/package
|
10 |
-
COPY metsa-frontend/package-lock.json ./package-lock.json
|
11 |
|
12 |
-
# Install dependencies
|
13 |
-
RUN npm
|
14 |
|
15 |
-
# Copy
|
16 |
-
COPY metsa-frontend/
|
17 |
|
18 |
-
# Build
|
19 |
RUN npm run build
|
20 |
|
21 |
-
#
|
22 |
-
FROM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
WORKDIR /app
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
RUN
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
# Ensure uploads directory exists with proper subdirectories
|
45 |
-
RUN mkdir -p metsa-backend/uploads/commercial \
|
46 |
-
&& mkdir -p metsa-backend/uploads/compliance \
|
47 |
-
&& mkdir -p metsa-backend/uploads/other
|
48 |
-
|
49 |
-
# Copy Next.js static export from builder stage
|
50 |
-
COPY --from=frontend-builder /app/frontend/out ./metsa-frontend/out
|
51 |
-
|
52 |
-
# Copy and prepare startup script
|
53 |
-
COPY scripts/start.sh ./scripts/start.sh
|
54 |
-
RUN chmod +x ./scripts/start.sh
|
55 |
-
|
56 |
-
# Set Python path
|
57 |
-
ENV PYTHONPATH=/app/metsa-backend
|
58 |
-
|
59 |
-
# Expose port
|
60 |
EXPOSE 8000
|
61 |
|
62 |
# Start the application
|
63 |
-
CMD ["
|
|
|
1 |
+
# Multi-stage build for the application
|
2 |
+
FROM node:18-alpine AS frontend-builder
|
3 |
|
4 |
+
# Set working directory for frontend build
|
|
|
5 |
WORKDIR /app/frontend
|
|
|
6 |
|
7 |
+
# Copy frontend package files
|
8 |
+
COPY metsa-frontend/package*.json ./
|
|
|
9 |
|
10 |
+
# Install frontend dependencies
|
11 |
+
RUN npm install --force
|
12 |
|
13 |
+
# Copy frontend source code
|
14 |
+
COPY metsa-frontend/ ./
|
15 |
|
16 |
+
# Build frontend
|
17 |
RUN npm run build
|
18 |
|
19 |
+
# Python dependencies stage
|
20 |
+
FROM python:3.11-slim AS python-deps
|
21 |
+
|
22 |
+
# Install system dependencies
|
23 |
+
RUN apt-get update && apt-get install -y \
|
24 |
+
gcc \
|
25 |
+
&& rm -rf /var/lib/apt/lists/*
|
26 |
+
|
27 |
+
# Set working directory
|
28 |
+
WORKDIR /app
|
29 |
+
|
30 |
+
# Copy backend requirements
|
31 |
+
COPY requirements.txt ./
|
32 |
+
|
33 |
+
# Install Python dependencies
|
34 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
35 |
+
|
36 |
+
# Final stage - Python runtime
|
37 |
+
FROM python:3.11-slim
|
38 |
+
|
39 |
+
# Install only runtime dependencies
|
40 |
+
RUN apt-get update && apt-get install -y \
|
41 |
+
libpq5 \
|
42 |
+
&& rm -rf /var/lib/apt/lists/*
|
43 |
+
|
44 |
+
# Set working directory
|
45 |
WORKDIR /app
|
46 |
+
|
47 |
+
# Copy installed packages from python-deps stage
|
48 |
+
COPY --from=python-deps /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
49 |
+
COPY --from=python-deps /usr/local/bin /usr/local/bin
|
50 |
+
|
51 |
+
# Copy backend application code
|
52 |
+
COPY metsa-backend/ ./
|
53 |
+
|
54 |
+
# Copy built frontend files from the builder stage to static directory
|
55 |
+
COPY --from=frontend-builder /app/frontend/out ./static
|
56 |
+
|
57 |
+
# Create uploads directory structure
|
58 |
+
RUN mkdir -p uploads/commercial \
|
59 |
+
&& mkdir -p uploads/compliance \
|
60 |
+
&& mkdir -p uploads/other
|
61 |
+
|
62 |
+
# Set environment variable for port
|
63 |
+
ENV PORT=8000
|
64 |
+
|
65 |
+
# Expose the port
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
EXPOSE 8000
|
67 |
|
68 |
# Start the application
|
69 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
scripts/build_frontend.sh
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
#!/usr/bin/env bash
|
2 |
-
set -euo pipefail
|
3 |
-
|
4 |
-
cd /app/metsa-frontend
|
5 |
-
export NEXT_TELEMETRY_DISABLED=1
|
6 |
-
npm ci
|
7 |
-
npm run build
|
8 |
-
# Remove the npm run export line - not needed with output: 'export'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/start.sh
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
#!/bin/bash
|
2 |
-
set -e
|
3 |
-
|
4 |
-
echo "Starting FastAPI backend..."
|
5 |
-
. /app/venv/bin/activate
|
6 |
-
cd /app/metsa-backend
|
7 |
-
exec python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|