socialboost / Dockerfile
ezequiellopez
fixing dockerfile
95871f8
raw
history blame
1.11 kB
# Dockerfile
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
# Set environment variables to prevent Python from writing pyc files to disk
# and to force unbuffered output (useful for Docker)
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV HF_HOME "app/cache"
ENV TRANSFORMERS_CACHE "app/cache"
### Set up user with permissions
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Switch to the "user" user
USER user
# Set the working directory in the container
WORKDIR /app
# Upgrade pip to the latest version and install Python dependencies
COPY --chown=user requirements.txt .
#RUN chown -R user:user /app
RUN pip install --upgrade pip && pip install -r requirements.txt
# Copy the FastAPI application code and other necessary files into the container
COPY --chown=user:user ./app .
COPY --chown=user:user .env .
RUN ls
### Update permissions for the app
USER root
RUN chmod 777 .
USER user
# Expose port 7860 for the application
EXPOSE 7860
# Command to run the FastAPI application using uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]