2024-10-12 14:46:41 +02:00
|
|
|
# Use the specified base image
|
2024-10-26 22:15:28 +02:00
|
|
|
|
|
|
|
# lutzapps - use uppercase "AS"
|
2024-10-31 21:10:28 +01:00
|
|
|
FROM madiator2011/better-base:cuda12.4 AS base
|
2024-10-26 22:15:28 +02:00
|
|
|
|
|
|
|
# lutzapps - prepare for local developement and debugging
|
|
|
|
# needed to change the ORDER of "apt-get commands" and move the "update-alternatives" for python3
|
|
|
|
# AFTER the "apt-get remove -y python3.10" cmd, OTHERWISE the symlink to python3
|
|
|
|
# is broken in the image and the VSCode debugger could not exec "python3" as CMD overwrite
|
2024-10-12 14:46:41 +02:00
|
|
|
|
|
|
|
# Install Python 3.11, set it as default, and remove Python 3.10
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y python3.11 python3.11-venv python3.11-dev python3.11-distutils aria2 git \
|
|
|
|
pv git rsync zstd libtcmalloc-minimal4 bc nginx ffmpeg && \
|
2024-10-26 22:15:28 +02:00
|
|
|
apt-get remove -y python3.10 python3.10-minimal libpython3.10-minimal libpython3.10-stdlib && \
|
2024-10-12 14:46:41 +02:00
|
|
|
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 && \
|
|
|
|
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
|
|
|
|
apt-get autoremove -y && \
|
|
|
|
apt-get clean && \
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# Install pip for Python 3.11
|
|
|
|
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
|
|
|
|
python3.11 get-pip.py && \
|
|
|
|
rm get-pip.py
|
|
|
|
|
|
|
|
# Set the working directory
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Copy the requirements file
|
|
|
|
COPY requirements.txt .
|
|
|
|
|
2024-10-26 22:15:28 +02:00
|
|
|
# Install the Python dependencies (as "managed pip")
|
2024-10-12 14:46:41 +02:00
|
|
|
RUN python3.11 -mpip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
# Copy the application code
|
2024-10-26 22:15:28 +02:00
|
|
|
# lutzapps - only copy the "app" folder and not the root (".") to avoid cluttering the docker container with src-files
|
|
|
|
COPY app .
|
2024-10-12 14:46:41 +02:00
|
|
|
|
|
|
|
# Install File Browser
|
|
|
|
RUN curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
|
|
|
|
|
2024-10-26 22:15:28 +02:00
|
|
|
# Set environment variables for developent/production
|
|
|
|
# overwrite this ENV in "tasks.json" docker run "env" section or overwrite in your ".env" file to "development"
|
2024-10-12 14:46:41 +02:00
|
|
|
ENV FLASK_ENV=production
|
2024-10-26 22:15:28 +02:00
|
|
|
|
|
|
|
# gevent monkey-patching is being used, enable gevent support in the debugger with GEVENT_SUPPORT=True
|
|
|
|
# add this ENV in "tasks.json" docker run "env" section or populate in your ".env" file
|
|
|
|
# ENV GEVENT_SUPPORT=True
|
|
|
|
|
|
|
|
# lutzapps - keep Python from generating .pyc files in the container
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
|
|
|
|
# Turns off buffering for easier container logging
|
2024-10-12 14:46:41 +02:00
|
|
|
ENV PYTHONUNBUFFERED=1
|
2024-10-26 22:15:28 +02:00
|
|
|
|
2024-10-12 14:46:41 +02:00
|
|
|
ENV APP_PATH=/app/app.py
|
|
|
|
|
|
|
|
# Expose the port Nginx will listen on
|
|
|
|
EXPOSE 7222
|
|
|
|
|
2024-10-26 22:15:28 +02:00
|
|
|
# lutzapps - moved the 4 static assets (3x PNG, 1x MP3) into the /app/static" folder for cleaner view
|
|
|
|
# lutzapps - added a "app/tests" folder with script and testdata and readme file
|
|
|
|
# lutzapps - grouped NGINX files in a sub-folder for cleaner view
|
|
|
|
|
2024-10-12 14:46:41 +02:00
|
|
|
# Copy the README.md
|
2024-10-26 22:15:28 +02:00
|
|
|
COPY nginx/README.md /usr/share/nginx/html/README.md
|
2024-10-12 14:46:41 +02:00
|
|
|
|
|
|
|
# NGINX configuration
|
2024-10-26 22:15:28 +02:00
|
|
|
COPY nginx/nginx.conf /etc/nginx/nginx.conf
|
|
|
|
COPY nginx/readme.html /usr/share/nginx/html/readme.html
|
2024-10-12 14:46:41 +02:00
|
|
|
|
|
|
|
# Copy all necessary scripts
|
|
|
|
COPY --from=scripts start.sh /
|
2024-10-26 22:15:28 +02:00
|
|
|
# --from=scripts is defined as a "shared" location in "docker-bake.hcl" in the "contexts" dict:
|
|
|
|
# scripts = "../../container-template"
|
|
|
|
# the local "start.sh" is (intentionally) empty
|
|
|
|
# to build all from *one* location, copy "start.sh" here into the project workspace folder first
|
|
|
|
# cp ../../container-template/scripts/start.sh start.sh
|
|
|
|
#COPY start.sh /
|
|
|
|
|
|
|
|
COPY pre_start.sh /
|
|
|
|
# lutzapps - add execution flags to added "/app/tests/populate_testdata.sh"
|
|
|
|
RUN chmod +x /pre_start.sh /start.sh /app/tests/populate_testdata.sh
|
|
|
|
|
2024-10-12 14:46:41 +02:00
|
|
|
# Copy the download_venv.sh script and make it executable
|
|
|
|
COPY download_venv.sh /app/download_venv.sh
|
|
|
|
RUN chmod +x /app/download_venv.sh
|
|
|
|
|
|
|
|
# CMD
|
2024-10-26 22:15:28 +02:00
|
|
|
# During debugging, this entry point will be overridden as "python3".
|
|
|
|
# For more information, please refer to https://aka.ms/vscode-docker-python-debug
|
2024-10-12 14:46:41 +02:00
|
|
|
CMD ["/start.sh"]
|