File size: 2,356 Bytes
4b130b1
 
f0988d8
4b130b1
 
f0988d8
4b130b1
f0988d8
4b130b1
035f8fd
4b130b1
f0988d8
 
 
 
4b130b1
 
f0988d8
 
2a0d3d8
f0988d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76135c2
f0988d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a478be1
 
 
 
f0988d8
 
 
 
 
a478be1
f0988d8
 
 
 
 
 
 
2a0d3d8
f0988d8
 
 
 
 
 
 
 
 
 
 
 
 
 
9fe3e06
 
f0988d8
9fe3e06
f0988d8
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Stage 1: Build the React dashboard with Bun.
FROM oven/bun:1 AS dashboard-builder
WORKDIR /app/pinchtab/dashboard
COPY pinchtab/dashboard/package.json pinchtab/dashboard/bun.lock ./
RUN bun install --frozen-lockfile
COPY pinchtab/dashboard/ .
RUN bun run build

# Stage 2: Compile the Go binary.
FROM golang:1.25-alpine AS go-builder
RUN apk add --no-cache git
WORKDIR /app/pinchtab
COPY pinchtab/go.mod pinchtab/go.sum ./
RUN go mod download
COPY pinchtab/ .
# Create missing embedded files if they don't exist
RUN touch internal/assets/stealth.js internal/assets/readability.js
COPY --from=dashboard-builder /app/pinchtab/dashboard/dist/ internal/dashboard/dashboard/
RUN mv internal/dashboard/dashboard/index.html internal/dashboard/dashboard/dashboard.html || true
RUN go build -o /pinchtab_bin ./cmd/pinchtab

# Final stage
FROM python:3.12-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    chromium \
    chromium-driver \
    libnss3 \
    libasound2 \
    libatk1.0-0 \
    libcairo2 \
    libcups2 \
    libdbus-1-3 \
    libexpat1 \
    libfontconfig1 \
    libgbm1 \
    libgcc1 \
    libglib2.0-0 \
    libgtk-3-0 \
    libnspr4 \
    libpango-1.0-0 \
    libpangocairo-1.0-0 \
    libstdc++6 \
    libx11-6 \
    libx11-xcb1 \
    libxcb1 \
    libxcomposite1 \
    libxcursor1 \
    libxdamage1 \
    libxext6 \
    libxfixes3 \
    libxi6 \
    libxrandr2 \
    libxrender1 \
    libxss1 \
    libxtst6 \
    ca-certificates \
    fonts-liberation \
    lsb-release \
    xdg-utils \
    wget \
    curl \
    git \
    rustc \
    cargo \
    pkg-config \
    libssl-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy and install Python dependencies
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application
COPY . .

# Copy the Pinchtab binary
COPY --from=go-builder /pinchtab_bin /usr/local/bin/pinchtab

# Expose ports (FastAPI/Gradio)
EXPOSE 7860
# Pinchtab
EXPOSE 9867

# Create a non-root user
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONPATH=/app

# Setup entrypoint
# Copy as root, chmod as root, then everything else is fine
USER root
RUN chmod +x entrypoint.sh
USER user

ENTRYPOINT ["./entrypoint.sh"]