From bc7440e7afe22c3fb19a7d595b07e34f2ac10463 Mon Sep 17 00:00:00 2001 From: casjay Date: Wed, 12 Oct 2022 21:15:38 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Committing=20everything?= =?UTF-8?q?=20that=20changed=20=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 9 +++++---- bin/entrypoint-bun.sh | 16 ++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index e7ba0f5..0e79504 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,19 +14,21 @@ ENV TZ="$TIMEZONE" \ BUN_INSTALL="/usr/local/share/bun" RUN set -ex; \ + mkdir -p "/usr/local/share/template-files/data/htdocs/www" && \ rm -Rf "/etc/apk/repositories"; \ echo "http://dl-cdn.alpinelinux.org/alpine/$alpine_version/main" >> "/etc/apk/repositories"; \ echo "http://dl-cdn.alpinelinux.org/alpine/$alpine_version/community" >> "/etc/apk/repositories"; \ if [ "$alpine_version" = "edge" ]; then echo "http://dl-cdn.alpinelinux.org/alpine/$alpine_version/testing" >> "/etc/apk/repositories" ; fi ; \ apk update --update-cache && \ curl -fsSL https://bun.sh/install | bash && \ - ln -sf /usr/local/share/bun/bun /usr/local/bin + ln -sf /usr/local/share/bun/bun /usr/local/bin && \ + git clone -q "https://github.com/casjay-templates/bunjs" "/usr/local/share/template-files/data/htdocs/www" COPY ./bin/. /usr/local/bin/ COPY ./data/. /usr/local/share/template-files/data/ COPY ./config/. /usr/local/share/template-files/config/ -RUN rm -Rf /bin/.gitkeep /config /data /var/cache/apk/* +RUN rm -Rf /bin/.gitkeep /config /data /var/cache/apk/* /usr/local/share/template-files/data/htdocs/www/.git FROM scratch ARG BUILD_DATE="2022-10-12" \ @@ -60,7 +62,7 @@ ENV SHELL="/bin/bash" \ COPY --from=build /. / -WORKDIR /data +WORKDIR /data/htdocs/www VOLUME [ "/config","/data" ] @@ -69,4 +71,3 @@ EXPOSE $PORTS ENTRYPOINT [ "tini", "-p", "SIGTERM", "--" ] CMD [ "/usr/local/bin/entrypoint-bun.sh" ] HEALTHCHECK --start-period=1m --interval=2m --timeout=3s CMD [ "/usr/local/bin/entrypoint-bun.sh", "healthcheck" ] - diff --git a/bin/entrypoint-bun.sh b/bin/entrypoint-bun.sh index 9730364..6f6a09f 100755 --- a/bin/entrypoint-bun.sh +++ b/bin/entrypoint-bun.sh @@ -119,10 +119,10 @@ if [ ! -e "/config/$APPNAME" ] && [ -e "$DEFAULT_CONF_DIR/$APPNAME" ]; then fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Setup bun -mkdir -p "/data" && cd "/data" || exit 10 -if [ -z "$1" ] && [ -z "$(ls -A "/app"/* 2>/dev/null)" ]; then - mkdir -p "/data" && cd "/data" - bun upgrade && bun init +mkdir -p "/data/htdocs/www" && cd "/data/htdocs/www" || exit 10 +if [ -z "$1" ] && [ -z "$(ls -A "/data/htdocs/www"/* 2>/dev/null)" ]; then + cp -Rf "/usr/local/share/template-files/data/htdocs/www/." "/data/htdocs/www/" + RUN_SCRIPT="src/index.ts" fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Additional commands @@ -155,7 +155,11 @@ bun) *) # Execute primary command if [ $# -eq 0 ]; then - if [ -f "index.ts" ]; then + if [ -n "$RUN_SCRIPT" ]; then + START_SCRIPT="$RUN_SCRIPT" + elif [ -f "src/index.ts" ]; then + RUN_SCRIPT="index.ts" + elif [ -f "index.ts" ]; then RUN_SCRIPT="index.ts" elif [ -f "app.ts" ]; then RUN_SCRIPT="app.ts" @@ -163,7 +167,7 @@ bun) RUN_SCRIPT="server.ts" fi bun install - bun dev $RUN_SCRIPT + bun dev ${START:-$START_SCRIPT} exit ${exitCode:-$?} else __exec_command "$@"