Translator / Dockerfile
feliksius's picture
Update Dockerfile
60a4195 verified
raw
history blame
1.07 kB
# 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"]