Skip to content

Commit

Permalink
rename init service to entrypoint
Browse files Browse the repository at this point in the history
* rename prepare.sh to docker-entrypoint.sh
* use ENTRYPOINT instead of CMD
  • Loading branch information
NicolasCARPi committed Aug 17, 2024
1 parent 58db89a commit d322071
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -323,23 +323,23 @@ HEALTHCHECK --interval=2m --timeout=5s --retries=3 CMD sh /etc/nginx/healthcheck
EXPOSE 443
# END NGINX PART 2

# PREPARE.SH
# ENTRYPOINT
# create a oneshot service
RUN mkdir -p /etc/s6-overlay/s6-rc.d/init && echo "oneshot" > /etc/s6-overlay/s6-rc.d/init/type
COPY ./src/init/up /etc/s6-overlay/s6-rc.d/init/
RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/init
RUN mkdir -p /etc/s6-overlay/s6-rc.d/entrypoint && echo "oneshot" > /etc/s6-overlay/s6-rc.d/entrypoint/type
COPY ./src/entrypoint/up /etc/s6-overlay/s6-rc.d/entrypoint/
RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/entrypoint

# prepare.sh must run before nginx and php are started
RUN echo "init" > /etc/s6-overlay/s6-rc.d/nginx/dependencies
RUN echo "init" > /etc/s6-overlay/s6-rc.d/php/dependencies
RUN echo "init" > /etc/s6-overlay/s6-rc.d/cron/dependencies
# docker-entrypoint.sh must run before nginx, php and cron are started
RUN echo "entrypoint" > /etc/s6-overlay/s6-rc.d/nginx/dependencies
RUN echo "entrypoint" > /etc/s6-overlay/s6-rc.d/php/dependencies
RUN echo "entrypoint" > /etc/s6-overlay/s6-rc.d/cron/dependencies

COPY ./src/init/prepare.sh /usr/sbin/prepare.sh
COPY ./src/entrypoint/docker-entrypoint.sh /usr/sbin/docker-entrypoint.sh
# these values are not in env and cannot be accessed by script so modify them here
RUN sed -i -e "s/%ELABIMG_VERSION%/$ELABIMG_VERSION/" \
-e "s/%ELABFTW_VERSION%/$ELABFTW_VERSION/" \
-e "s/%S6_OVERLAY_VERSION%/$S6_OVERLAY_VERSION/" /usr/sbin/prepare.sh
# END PREPARE.SH
-e "s/%S6_OVERLAY_VERSION%/$S6_OVERLAY_VERSION/" /usr/sbin/docker-entrypoint.sh
# END DOCKER-ENTRYPOINT.SH

# CRONIE
COPY --from=cronie-builder --chown=root:root /build/apk /tmp/cronie.apk
Expand All @@ -354,7 +354,7 @@ COPY --from=invoker-builder /app/invoker /usr/bin/invoker
RUN chmod +x /usr/bin/invoker

# add a helper script to reload services easily
COPY ./src/init/reload.sh /usr/bin/reload
COPY ./src/entrypoint/reload.sh /usr/bin/reload
RUN chmod 700 /usr/bin/reload

# this is unique to the build and is better than the previously used elabftw version for asset cache busting
Expand All @@ -363,4 +363,4 @@ RUN sed -i -e "s/%ELABIMG_BUILD_ID%/$(openssl rand -hex 4)/" /etc/php83/php-fpm.
RUN chmod 400 /etc/php83/php-fpm.d/elabpool.conf

# start s6
CMD ["/init"]
ENTRYPOINT ["/init"]
2 changes: 1 addition & 1 deletion src/init/README.md → src/entrypoint/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Prepare script
# docker-entrypoint.sh

## Description

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/entrypoint/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/command/with-contenv sh
/command/with-contenv /usr/sbin/docker-entrypoint.sh
2 changes: 0 additions & 2 deletions src/init/up

This file was deleted.

0 comments on commit d322071

Please sign in to comment.