Skip to content

Commit

Permalink
wrap entrypoint script to trigger pre/post hook commands (#435)
Browse files Browse the repository at this point in the history
* wrapped entrypoint script in runner script to trigger pre/post hook commands

* updated changelog and added comment
  • Loading branch information
adwk67 authored Aug 17, 2023
1 parent bf6ecd1 commit e7f6fe2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions airflow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
- Updated Vector to 0.31 ([#429]).
- Updated git-sync to 3.6.8 ([#431]).
- Updated statsd-exporter to 0.24, this was accidentally moved to a very old version previously (0.3.0) ([#431]).
- Added wrapper script to allow the triggering of pre/post hook actions ([#435]).

[#429]: https://github.com/stackabletech/docker-images/pull/429
[#431]: https://github.com/stackabletech/docker-images/pull/431
[#435]: https://github.com/stackabletech/docker-images/pull/435

## [23.7.0]

Expand Down
8 changes: 5 additions & 3 deletions airflow/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ RUN chown --recursive stackable:stackable ${AIRFLOW_HOME}
# Get the correct `tini` binary for our architecture.
# It is used as an init alternative in the entrypoint
RUN curl --fail -o /usr/bin/tini "https://repo.stackable.tech/repository/packages/tini/tini-${TINI}-$(arch)"
COPY airflow/stackable/utils/entrypoint.sh /entrypoint
RUN chmod a+x /entrypoint && \
COPY airflow/stackable/utils/entrypoint.sh /entrypoint.sh
COPY airflow/stackable/utils/run-airflow.sh /run-airflow.sh
RUN chmod a+x /entrypoint.sh && \
chmod a+x /run-airflow.sh && \
chmod +x /usr/bin/tini

COPY --from=statsd-exporter --chown=stackable:stackable /bin/statsd_exporter /stackable/statsd_exporter
Expand All @@ -101,5 +103,5 @@ COPY --from=gitsync-image --chown=stackable:stackable /git-sync /stackable/git-s
USER stackable
WORKDIR /stackable

ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint"]
ENTRYPOINT ["/usr/bin/tini", "--", "/run-airflow.sh"]
CMD []
14 changes: 14 additions & 0 deletions airflow/stackable/utils/run-airflow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# This wrapper script allows commands that are embedded in environment variables
# to be invoked to carry out actions when the main container is complete.
# N.B. for airflow services (scheduler, webserver, worker) this will not be relevant
# as the service has to be terminated, but for pods spawned and terminated by the
# kubernetes executor this allows us to stop other containers, such as vector.
eval "$_STACKABLE_PRE_HOOK"

/entrypoint.sh "$@"
result=$?

eval "$_STACKABLE_POST_HOOK"

exit $result

0 comments on commit e7f6fe2

Please sign in to comment.