File size: 885 Bytes
a9b39d2
2926041
 
a9b39d2
2926041
 
 
 
 
 
 
 
 
 
 
 
a9b39d2
 
2926041
a9b39d2
 
2926041
 
 
 
 
 
 
a9b39d2
 
2926041
a9b39d2
2926041
a9b39d2
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Use an official Python runtime as a parent image
FROM python:3.10-slim-bullseye

# Set Python to use unbuffered mode
ENV PYTHONUNBUFFERED=1

ENV PATH="/var/www/.local/bin:${PATH}"

# Create a non-root user
RUN useradd -m -u 1000 -U -s /bin/bash myuser

# Install dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends python3-pip python3-dev && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
RUN mkdir /var/www
ENV HOME=/var/www
WORKDIR /var/www

# Change ownership of /var/www to the non-root user
RUN chown -R myuser:myuser /var/www

# Switch to the non-root user
USER myuser

# Copy the current directory contents into the container at /var/www
COPY . /var/www

RUN pip install --user -r requirements.txt

# Expose the port
EXPOSE 7860

# Run app.py when the container launches
CMD flask run --host=0.0.0.0 --port=7860