Modify container signal handling
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 1m11s
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 1m11s
This commit is contained in:
13
dockerfile
13
dockerfile
@@ -4,12 +4,6 @@ FROM python:3.11-slim
|
|||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Docker process manager
|
|
||||||
ENV TINI_VERSION v0.19.0
|
|
||||||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
|
|
||||||
RUN chmod +x /tini
|
|
||||||
ENTRYPOINT ["/tini", "--"]
|
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
gcc \
|
gcc \
|
||||||
@@ -38,6 +32,9 @@ RUN mkdir -p logs && \
|
|||||||
chown -R bot:bot embed && \
|
chown -R bot:bot embed && \
|
||||||
chmod -R 777 embed
|
chmod -R 777 embed
|
||||||
|
|
||||||
|
# Make the entrypoint script executable
|
||||||
|
RUN chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
# Switch to non root user
|
# Switch to non root user
|
||||||
USER bot
|
USER bot
|
||||||
|
|
||||||
@@ -45,5 +42,5 @@ USER bot
|
|||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
ENV CONFIG_PATH=/app/config.ini
|
ENV CONFIG_PATH=/app/config.ini
|
||||||
|
|
||||||
# Command to run the bot (using exec form and signal handling)
|
# Run the bot using the entrypoint script
|
||||||
CMD ["sh", "-c", "python generate_config.py && exec python pterodisbot.py"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
13
entrypoint.sh
Normal file
13
entrypoint.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Run the application in the background
|
||||||
|
python generate_config.py && python pterodisbot.py &
|
||||||
|
|
||||||
|
# Capture the process ID
|
||||||
|
PID=$!
|
||||||
|
|
||||||
|
# Wait for SIGTERM signal
|
||||||
|
trap "kill -INT $PID" SIGTERM
|
||||||
|
|
||||||
|
# Wait for the process to complete
|
||||||
|
wait $PID
|
Reference in New Issue
Block a user