12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- FROM python:3.10
- # Install pip
- RUN python -m ensurepip --upgrade
- RUN pip install --upgrade pip
- RUN pip install virtualenv
- RUN apt-get update && apt-get install locate sudo
- # Create and activate virtual environment
- RUN virtualenv --copies /venv
- RUN chmod 777 /venv
- # ENV PATH="/venv/bin:$PATH"
- RUN . /venv/bin/activate
- # RUN cd / | tar -czvf venv.tar.gz venv
- # Set working directory
- WORKDIR /app
- # Copy requirements.txt and install dependencies
- COPY requirements.txt .
- RUN pip install -r requirements.txt
- RUN pip install venv-pack
- # RUN cd /venv && tar -czvf ../venv.tar.gz * && chmod 777 ../venv.tar.gz
- # RUN stat /venv.tar.gz
- RUN venv-pack -p /venv -o /venv.tar.gz && chmod 777 /venv.tar.gz
- # set new user
- RUN echo "meowuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
- && groupadd -g 9882 meowuser && useradd -u 9882 -g 9882 meowuser
- RUN echo "meowuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
- # Create the home directory for meowuser
- RUN mkdir -p /home/meowuser && \
- chown meowuser:meowuser /home/meowuser
- # Set the working directory to /home/meowuser
- WORKDIR /home/meowuser
- USER meowuser
- RUN cp /venv.tar.gz /home/meowuser
- # Copy the rest of the application code
- COPY app.py /home/meowuser
- # tar -czvf archive.tar.gz folder_name
- # Set the command to run the application
- CMD [ "python", "app.py" ]
|