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
|
||||
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
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gcc \
|
||||
@@ -38,6 +32,9 @@ RUN mkdir -p logs && \
|
||||
chown -R bot:bot embed && \
|
||||
chmod -R 777 embed
|
||||
|
||||
# Make the entrypoint script executable
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
|
||||
# Switch to non root user
|
||||
USER bot
|
||||
|
||||
@@ -45,5 +42,5 @@ USER bot
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV CONFIG_PATH=/app/config.ini
|
||||
|
||||
# Command to run the bot (using exec form and signal handling)
|
||||
CMD ["sh", "-c", "python generate_config.py && exec python pterodisbot.py"]
|
||||
# Run the bot using the entrypoint script
|
||||
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