Update Dockerfile
Browse files- Dockerfile +18 -13
Dockerfile
CHANGED
|
@@ -1,32 +1,37 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
-
# Create a non-root user
|
| 4 |
-
RUN adduser --disabled-password --gecos ''
|
| 5 |
mkdir -p /app && \
|
| 6 |
-
chown -R
|
| 7 |
|
| 8 |
# Install system dependencies
|
| 9 |
-
RUN apt update && apt upgrade -y
|
| 10 |
-
apt install git -y
|
| 11 |
|
| 12 |
# Copy requirements and install
|
| 13 |
COPY requirements.txt /requirements.txt
|
| 14 |
-
RUN pip install
|
| 15 |
-
pip install -
|
| 16 |
|
| 17 |
# Switch to non-root user
|
| 18 |
-
USER
|
| 19 |
WORKDIR /app
|
| 20 |
|
| 21 |
-
# Copy application files
|
| 22 |
-
COPY --chown=
|
| 23 |
|
| 24 |
-
# Set environment variables
|
| 25 |
ENV LOG_PATH=/app/BotLog.txt
|
|
|
|
| 26 |
ENV FLASK_DEBUG=0
|
|
|
|
|
|
|
| 27 |
|
| 28 |
# Ensure the log file is writable
|
| 29 |
RUN touch $LOG_PATH && chmod 666 $LOG_PATH
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
|
| 3 |
+
# Create a non-root user with valid username format
|
| 4 |
+
RUN adduser --disabled-password --gecos '' professor && \
|
| 5 |
mkdir -p /app && \
|
| 6 |
+
chown -R professor:professor /app
|
| 7 |
|
| 8 |
# Install system dependencies
|
| 9 |
+
RUN apt-get update && apt-get upgrade -y
|
|
|
|
| 10 |
|
| 11 |
# Copy requirements and install
|
| 12 |
COPY requirements.txt /requirements.txt
|
| 13 |
+
RUN pip install --upgrade pip && \
|
| 14 |
+
pip install -r /requirements.txt
|
| 15 |
|
| 16 |
# Switch to non-root user
|
| 17 |
+
USER professor
|
| 18 |
WORKDIR /app
|
| 19 |
|
| 20 |
+
# Copy application files
|
| 21 |
+
COPY --chown=professor:professor . .
|
| 22 |
|
| 23 |
+
# Set environment variables
|
| 24 |
ENV LOG_PATH=/app/BotLog.txt
|
| 25 |
+
ENV FLASK_APP=app.py
|
| 26 |
ENV FLASK_DEBUG=0
|
| 27 |
+
ENV FLASK_RUN_HOST=0.0.0.0
|
| 28 |
+
ENV FLASK_RUN_PORT=7860
|
| 29 |
|
| 30 |
# Ensure the log file is writable
|
| 31 |
RUN touch $LOG_PATH && chmod 666 $LOG_PATH
|
| 32 |
|
| 33 |
+
# Expose port
|
| 34 |
+
EXPOSE 7860
|
| 35 |
+
|
| 36 |
+
# Run both services
|
| 37 |
+
CMD ["sh", "-c", "python bot.py & flask run"]
|