Skip to content

Commit

Permalink
feat: run entrypoint as s6 supervised service
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Riben <matt.riben@swirldslabs.com>
  • Loading branch information
matteriben committed Oct 11, 2024
1 parent dd6203c commit 7dfd8da
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,13 @@ COPY sdk/data/lib/* /opt/hgcapp/services-hedera/HapiApp2.0/data/lib/
# Add the entrypoint script
ADD entrypoint.sh /opt/hgcapp/services-hedera/HapiApp2.0/

# Add s6-rc configuration
COPY etc/s6-overlay/s6-rc.d /etc/s6-overlay/s6-rc.d/

# Ensure proper file permissions
RUN chmod -R +x /opt/hgcapp/services-hedera/HapiApp2.0/entrypoint.sh && \
chown -R 2000:2000 /opt/hgcapp/services-hedera/HapiApp2.0
chown -R 2000:2000 /opt/hgcapp/services-hedera/HapiApp2.0 && \
chmod -R +x /etc/s6-overlay/s6-rc.d/hedera

########################################
#### Deterministic Build Hack ####
Expand Down Expand Up @@ -275,6 +279,9 @@ ENV MALLOC_ARENA_MAX 4
# Log Folder Name Override
ENV LOG_DIR_NAME ""

# Customize s6-overlay
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME 0

# Define Volume Bindpoints
VOLUME "/opt/hgcapp/accountBalances"
VOLUME "/opt/hgcapp/eventsStreams"
Expand All @@ -294,4 +301,3 @@ EXPOSE 50111/tcp 50211/tcp 50212/tcp
USER 2000
WORKDIR "/opt/hgcapp"
ENTRYPOINT ["/init"]
CMD ["/opt/hgcapp/services-hedera/HapiApp2.0/entrypoint.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function waitForFile() {
[[ -z "${fileName}" ]] && return 1
for (( attempts = 0; attempts < 20; attempts++ )); do
if [[ -f "${fileName}" ]]; then
size="$(stat -f '+%z' "${fileName}")"
size="$(stat --format '%s' "${fileName}")"
[[ -n "${size}" && "${size}" -gt 0 ]] && return 0
fi
sleep 6
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/hedera/up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /usr/bin/env bash

/opt/hgcapp/services-hedera/HapiApp2.0/entrypoint.sh
echo ${?} | tee --output-error=warn /run/s6-linux-init-container-results/exitcode > /dev/null
exit 0

0 comments on commit 7dfd8da

Please sign in to comment.