Change to gunicorn and update variable names

This commit is contained in:
ksyasuda 2024-09-05 04:34:00 -07:00
parent f0a84c1f41
commit 492f68e0f8
No known key found for this signature in database
3 changed files with 11 additions and 12 deletions

View File

@ -2,16 +2,14 @@
FROM python:3.10-slim FROM python:3.10-slim
# Set environment variables for the MPV socket and server host/port # Set environment variables for the MPV socket and server host/port
ENV MPV_SOCKET="/tmp/mpvsocket" \ ENV LISTEN_ADDRESS="0.0.0.0" \
HOST_NAME="0.0.0.0" \ LISTEN_PORT=8080
PORT_NUMBER=8080 \
LOGLEVEL="info"
# Set the working directory in the container # Set the working directory in the container
WORKDIR /app WORKDIR /app
# Copy the current directory contents into the container at /app # Copy the current directory contents into the container at /app
COPY server.py /app/server.py COPY server.py requirements.txt /app/
# Install any needed packages specified in requirements.txt # Install any needed packages specified in requirements.txt
# If there are no external dependencies, you can skip this step # If there are no external dependencies, you can skip this step
@ -20,7 +18,8 @@ COPY server.py /app/server.py
# Make port 8080 available to the world outside this container # Make port 8080 available to the world outside this container
EXPOSE "${PORT_NUMBER}" EXPOSE "${PORT_NUMBER}"
RUN pip3 install --no-cache-dir Flask mysql-connector-python RUN pip3 install --no-cache-dir -r requirements.txt
# Run server.py when the container launches # Run server.py when the container launches
CMD ["python3", "server.py", "--host", "${HOST_NAME}", "--port", "${PORT_NUMBER}", "--input-ipc-server", "${MPV_SOCKET}"] # CMD ["python3", "server.py", "--host", "${LISTEN_ADDRESS}", "--port", "${LISTEN_PORT}", "--input-ipc-server", "${MPV_SOCKET}"]
CMD gunicorn --bind "${LISTEN_ADDRESS}":"${LISTEN_PORT}" server:app

View File

@ -1,7 +1,6 @@
IP=0.0.0.0 # Lisen on all interfaces LISTEN_ADDRESS=0.0.0.0 # Lisen on all interfaces
PORT_NUMBER=8080 # Internal port number LISTEN_PORT=8080 # Internal port number
MPV_SOCKET=/tmp/mpvsocket # Path to mpv socket MPV_SOCKET=/tmp/mpvsocket # Path to mpv socket
LOGLEVEL=info
# MySQL connection info # MySQL connection info
MYSQL_HOST=localhost MYSQL_HOST=localhost
@ -10,3 +9,4 @@ MYSQL_PASSWORD=SecretPassword
MYSQL_DATABASE=mpv MYSQL_DATABASE=mpv
MYSQL_PORT=3306 MYSQL_PORT=3306
LOGLEVEL=info

View File

@ -8,8 +8,8 @@ WorkingDirectory=<PATH_TO_PYTHON_SCRIPT>
ExecStart=<PATH_TO_PYTHON> <PATH_TO_PYTHON_SCRIPT> ExecStart=<PATH_TO_PYTHON> <PATH_TO_PYTHON_SCRIPT>
Restart=on-failure Restart=on-failure
Environment="MPV_SOCKET=/tmp/mpvsocket" Environment="MPV_SOCKET=/tmp/mpvsocket"
Environment="HOST_NAME=0.0.0.0" Environment="LISTEN_ADDRESS=0.0.0.0"
Environment="PORT_NUMBER=42069" Environment="LISTEN_PORT=42069"
Environment="MYSQL_HOST=http://localhost" Environment="MYSQL_HOST=http://localhost"
Environment="MYSQL_USER=mpvuser" Environment="MYSQL_USER=mpvuser"
Environment="MYSQL_PASSWORD=SecretPassword" Environment="MYSQL_PASSWORD=SecretPassword"