Dockerfile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. FROM python:3.10
  2. # Install pip
  3. RUN python -m ensurepip --upgrade
  4. RUN pip install --upgrade pip
  5. RUN pip install virtualenv
  6. RUN apt-get update && apt-get install locate sudo
  7. # Create and activate virtual environment
  8. RUN virtualenv --copies /venv
  9. RUN chmod 777 /venv
  10. # ENV PATH="/venv/bin:$PATH"
  11. RUN . /venv/bin/activate
  12. # RUN cd / | tar -czvf venv.tar.gz venv
  13. # Set working directory
  14. WORKDIR /app
  15. # Copy requirements.txt and install dependencies
  16. COPY requirements.txt .
  17. RUN pip install -r requirements.txt
  18. RUN pip install venv-pack
  19. # RUN cd /venv && tar -czvf ../venv.tar.gz * && chmod 777 ../venv.tar.gz
  20. # RUN stat /venv.tar.gz
  21. RUN venv-pack -p /venv -o /venv.tar.gz && chmod 777 /venv.tar.gz
  22. # set new user
  23. RUN echo "meowuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
  24. && groupadd -g 9882 meowuser && useradd -u 9882 -g 9882 meowuser
  25. RUN echo "meowuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
  26. # Create the home directory for meowuser
  27. RUN mkdir -p /home/meowuser && \
  28. chown meowuser:meowuser /home/meowuser
  29. # Set the working directory to /home/meowuser
  30. WORKDIR /home/meowuser
  31. USER meowuser
  32. RUN cp /venv.tar.gz /home/meowuser
  33. # Copy the rest of the application code
  34. COPY app.py /home/meowuser
  35. # tar -czvf archive.tar.gz folder_name
  36. # Set the command to run the application
  37. CMD [ "python", "app.py" ]