weather-app / Dockerfile
rrayhka's picture
Update Dockerfile
527a0ff verified
raw
history blame contribute delete
711 Bytes
# Gunakan Python 3.12.5 sebagai image dasar
FROM python:3.12.5-slim
# Tambahkan user non-root
RUN useradd -m -u 1000 user
USER user
# Tambahkan path untuk pip lokal
ENV PATH="/home/user/.local/bin:$PATH"
# Nonaktifkan CUDA untuk menghindari kesalahan terkait GPU
ENV CUDA_VISIBLE_DEVICES="-1"
# Set workdir
WORKDIR /app
# Salin file requirements.txt dan instal dependensi
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Salin semua file aplikasi ke dalam container
COPY --chown=user . /app
# Ekspos port Flask
EXPOSE 5000
# Jalankan aplikasi dengan Gunicorn untuk produksi
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]