Skip to content

Commit

Permalink
docker: add entrypoint.sh to support user-specified command to fix #104
Browse files Browse the repository at this point in the history
  • Loading branch information
p0n1 committed Jan 17, 2025
1 parent 56b0c57 commit c2b9701
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ RUN pip install --no-cache-dir -r requirements.txt
# Set the working directory to /app
WORKDIR /app

# Set this as the default command
# ENTRYPOINT [ "python", "/app_src/main.py" ]
# Copy and set the entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Set the entrypoint script as the default command
ENTRYPOINT ["/entrypoint.sh"]
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

echo "Starting entrypoint script..."

if [ "$1" = "python3" ] || [ "$1" = "python" ]; then
# If the first argument is python or python3, execute the user-specified command
echo "Executing user-specified python command: $@"
exec "$@"
else
# Otherwise, execute the default python3 /app_src/main.py command with all arguments
echo "Executing default command: python3 /app_src/main.py $@"
exec python3 /app_src/main.py "$@"
fi

0 comments on commit c2b9701

Please sign in to comment.