File size: 1,071 Bytes
02f8a29
60a4195
 
 
 
 
 
02f8a29
 
 
 
2d48165
 
 
19dec0c
 
 
60a4195
 
 
02f8a29
 
 
 
 
 
 
2d48165
 
 
 
19dec0c
 
 
02f8a29
 
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
# Gunakan image Python resmi
FROM python:3.9-slim@sha256:bef8d69306a7905f55cd523f5604de1dde45bbf745ba896dbb89f6d15c727170

# Instal dependensi sistem untuk opencc-python-reborn
RUN apt-get update && apt-get install -y --no-install-recommends \
    libopencc-dev \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Buat direktori cache dan atur izin
RUN mkdir -p /app/cache && chmod -R 777 /app/cache

# Bersihkan cache lama (untuk mencegah error izin)
RUN rm -rf /app/cache/* && chmod -R 777 /app/cache

# Upgrade pip untuk kompatibilitas paket terbaru
RUN pip install --upgrade pip

# Salin requirements.txt dan install dependensi
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Salin kode aplikasi
COPY app.py .

# Atur environment variable untuk cache
ENV HF_HOME=/app/cache
ENV TRANSFORMERS_CACHE=/app/cache

# Pastikan izin direktori cache tetap benar sebelum menjalankan aplikasi
RUN chmod -R 777 /app/cache

# Jalankan aplikasi dengan uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]