Skip to content

Commit

Permalink
fix after victor's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hlecuyer committed Aug 29, 2024
1 parent 67ec49e commit 170e8e8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ RUN useradd --no-log-init -g gunicorn gunicorn
# Copy venv with compiled dependencies
COPY --chown=gunicorn:gunicorn --from=compile-image /srv/venv /srv/venv

COPY --chown=gunicorn:gunicorn ["run_management_command.sh", "docker-entrypoint.sh", "pyproject.toml", "alembic.ini", "/srv/"]
COPY --chown=gunicorn:gunicorn ["execute_and_notify.sh", "docker-entrypoint.sh", "pyproject.toml", "alembic.ini", "/srv/"]
COPY --chown=gunicorn:gunicorn src /srv/src
COPY --chown=gunicorn:gunicorn tests /srv/tests


RUN chmod +x docker-entrypoint.sh
RUN chmod +x run_management_command.sh
RUN chmod +x execute_and_notify.sh

USER gunicorn
EXPOSE 8000
Expand Down
16 changes: 16 additions & 0 deletions api/execute_and_notify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
set -u

"$@" &
command_pid=$!
wait $command_pid

exit_code=$?
if [ $exit_code -ne 0 ] && [ "$ENV" = "prod" ]; then
# Execute the curl command in case of an error
escaped_command="\`$@\`"
echo "Error with exit code \`$exit_code\` in command $escaped_command, sending message to Mattermost"
curl -i -X POST -H "Content-Type: application/json" -d "{\"text\": \"Error with exit code \`$exit_code\` in command $escaped_command: \nLogs: \`scalingo --region osc-secnum-fr1 --app data-inclusion-api-prod logs --lines 1000 -F $CONTAINER -f\`\"}" $MATTERMOST_HOOK
fi

exit $exit_code
21 changes: 0 additions & 21 deletions api/run_management_command.sh

This file was deleted.

0 comments on commit 170e8e8

Please sign in to comment.