Skip to content

Commit

Permalink
Update entrypoint script to compile Python code efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed Mar 24, 2024
1 parent 6761907 commit c72919e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/python_compile/assets/debian-dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ COPY ${REQUIREMENTS_FILE} ./requirements.txt

# Build the entrypoint script in the container.
RUN echo '#!/bin/sh' > /entrypoint.sh && \
echo 'cd /host_dir' >> /entrypoint.sh && \
echo 'if [ -f "requirements.txt" ]; then pip install -r requirements.txt; fi' >> /entrypoint.sh && \
echo 'python -m nuitka --standalone --follow-imports --onefile --lto=yes --python-flag=-OO "$@"' >> /entrypoint.sh && \
echo 'for file in $(find . -type f -name "*.bin"); do chmod +x "$file"; done' >> /entrypoint.sh && \
echo 'for file in $(find . -type f -name "*.bin"); do gzip "$file"; done' >> /entrypoint.sh && \
echo 'mkdir /tmp_dir' >> /entrypoint.sh && \
echo 'cd /tmp_dir' >> /entrypoint.sh && \
echo 'if [ -f "/host_dir/requirements.txt" ]; then pip install -r /host_dir/requirements.txt; fi' >> /entrypoint.sh && \
echo 'python -m nuitka --standalone --follow-imports --onefile --lto=yes --python-flag=-OO /host_dir/"$@"' >> /entrypoint.sh && \
echo 'for file in $(find /tmp_dir -type f -name "*.bin"); do chmod +x "$file"; done' >> /entrypoint.sh && \
echo 'for file in $(find ;/tmp_dir -type f -name "*.bin"); do gzip "$file"; done' >> /entrypoint.sh && \
echo 'mv *.gz /host_dir/' >> /entrypoint.sh && \
chmod +x /entrypoint.sh

# Make the entrypoint script executable
Expand Down

0 comments on commit c72919e

Please sign in to comment.