A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
docker: Change all images to be built from the same AIO base
MohamedBassemc72dbd04e7b1
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlindex 52a14d95..027c7ad2 100644--- a/.github/workflows/docker.yml+++ b/.github/workflows/docker.yml@@ -12,7 +12,15 @@ jobs:strategy:fail-fast: falsematrix:- package: [web, workers, cli, aio]+ include:+ - package: hoarder-web+ target: web+ - package: hoarder-workers+ target: workers+ - package: hoarder-cli+ target: cli+ - package: hoarder+ target: aioruns-on: ubuntu-latestpermissions:packages: write@@ -36,12 +44,12 @@ jobs:context: .build-args: SERVER_VERSION=nightlyfile: docker/Dockerfile- target: ${{ matrix.package }}+ target: ${{ matrix.target }}platforms: linux/amd64,linux/arm64push: true- tags: ghcr.io/hoarder-app/hoarder-${{ matrix.package }}:latest,ghcr.io/mohamedbassem/hoarder-${{ matrix.package }}:latest- cache-from: type=registry,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.package }}- cache-to: type=registry,mode=max,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.package }}+ tags: ghcr.io/hoarder-app/${{ matrix.package }}:latest,ghcr.io/mohamedbassem/${{ matrix.package }}:latest+ cache-from: type=registry,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.target }}+ cache-to: type=registry,mode=max,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.target }}- name: Build ${{ matrix.package }} (release)uses: docker/build-push-action@v5@@ -50,9 +58,9 @@ jobs:context: .build-args: SERVER_VERSION=${{ github.event.release.name }}file: docker/Dockerfile- target: ${{ matrix.package }}+ target: ${{ matrix.target }}platforms: linux/amd64,linux/arm64push: true- tags: ghcr.io/hoarder-app/hoarder-${{ matrix.package }}:${{ github.event.release.name }},ghcr.io/hoarder-app/hoarder-${{ matrix.package }}:release,ghcr.io/mohamedbassem/hoarder-${{ matrix.package }}:${{ github.event.release.name }},ghcr.io/mohamedbassem/hoarder-${{ matrix.package }}:release- cache-from: type=registry,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.package }}- cache-to: type=registry,mode=max,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.package }}+ tags: ghcr.io/hoarder-app/${{ matrix.package }}:${{ github.event.release.name }},ghcr.io/hoarder-app/${{ matrix.package }}:release,ghcr.io/mohamedbassem/${{ matrix.package }}:${{ github.event.release.name }},ghcr.io/mohamedbassem/${{ matrix.package }}:release+ cache-from: type=registry,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.target }}+ cache-to: type=registry,mode=max,ref=ghcr.io/hoarder-app/hoarder-build-cache:${{ matrix.target }}diff --git a/docker/Dockerfile b/docker/Dockerfileindex 592c4cfd..ed8d51ca 100644--- a/docker/Dockerfile+++ b/docker/Dockerfile@@ -20,90 +20,110 @@ RUN cd packages/db && \cp -R drizzle /db_migrations-################# The Web builder ##############+# Compile the web app+RUN (cd apps/web && pnpm next experimental-compile)-# Rebuild the source code only when needed-FROM base AS web_builder+# Build the worker code+RUN --mount=type=cache,id=pnpm_workers,target=/pnpm/store pnpm deploy --node-linker=isolated --filter @hoarder/workers --prod /prod/workers-WORKDIR /app/apps/web+# Build the cli+RUN (cd apps/cli && pnpm build)-RUN pnpm next experimental-compile+################# The All-in-one builder ##############-################# The Web App ##############--FROM node:21-alpine AS web+FROM node:21-alpine AS aio_builderWORKDIR /app-ENV NODE_ENV production-ENV NEXT_TELEMETRY_DISABLED 1--COPY --from=web_builder --chown=node:node /app/apps/web/.next/standalone ./-COPY --from=web_builder /app/apps/web/public ./apps/web/public-COPY --from=web_builder /db_migrations /db_migrations--# Set the correct permission for prerender cache-RUN mkdir -p ./apps/web/.next-RUN chown node:node ./apps/web/.next--# Automatically leverage output traces to reduce image size-# https://nextjs.org/docs/advanced-features/output-file-tracing-COPY --from=web_builder --chown=node:node /app/apps/web/.next/static ./apps/web/.next/static+ARG SERVER_VERSION=nightly+ENV SERVER_VERSION=${SERVER_VERSION}-WORKDIR /app/apps/webUSER root-EXPOSE 3000ENV PORT 3000-# set hostname to localhostENV HOSTNAME "0.0.0.0"+EXPOSE 3000-ARG SERVER_VERSION=nightly-ENV SERVER_VERSION=${SERVER_VERSION}+######################+# Prepare s6-overlay+######################+ARG S6_OVERLAY_VERSION=3.2.0.0+ARG TARGETARCH-# server.js is created by next build from the standalone output-# https://nextjs.org/docs/pages/api-reference/next-config-js/output-CMD ["/bin/sh", "-c", "(cd /db_migrations && node index.js) && node server.js"]+ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp+RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \+ && case ${TARGETARCH} in \+ "amd64") S6_ARCH=x86_64 ;; \+ "arm64") S6_ARCH=aarch64 ;; \+ esac \+ && echo https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz -O /tmp/s6-overlay-${S6_ARCH}.tar.xz \+ && wget https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz -O /tmp/s6-overlay-${S6_ARCH}.tar.xz \+ && tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz \+ && rm -f /tmp/s6-overlay-${S6_ARCH}.tar.xz-################# The workers builder ##############+# Copy the s6-overlay config+COPY --chmod=755 ./docker/root/etc/s6-overlay /etc/s6-overlay-FROM base AS workers_builder+######################+# Install runtime deps+######################+RUN apk add --no-cache monolith-RUN --mount=type=cache,id=pnpm_workers,target=/pnpm/store pnpm deploy --node-linker=isolated --filter @hoarder/workers --prod /prod+######################+# Prepare the web app+######################-################# The workers ##############+ENV NODE_ENV production+ENV NEXT_TELEMETRY_DISABLED 1-FROM node:21-alpine AS workers-WORKDIR /app-RUN apk add --no-cache monolith+COPY --from=base --chown=node:node /app/apps/web/.next/standalone ./+COPY --from=base /app/apps/web/public ./apps/web/public+COPY --from=base /db_migrations /db_migrations++# Set the correct permission for prerender cache+RUN mkdir -p ./apps/web/.next && chown node:node ./apps/web/.next-COPY --from=workers_builder /prod apps/workers+# Automatically leverage output traces to reduce image size+# https://nextjs.org/docs/advanced-features/output-file-tracing+COPY --from=base --chown=node:node /app/apps/web/.next/static ./apps/web/.next/static+######################+# Prepare the workers app+######################+COPY --from=base /prod/workers /app/apps/workersRUN corepack enable-WORKDIR /app/apps/workers+ENTRYPOINT ["/init"]-USER root+################# The AIO ##############-ARG SERVER_VERSION=nightly-ENV SERVER_VERSION=${SERVER_VERSION}+FROM aio_builder AS aio-CMD ["pnpm", "run", "start:prod"]+RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/init-db-migration \+ /etc/s6-overlay/s6-rc.d/user/contents.d/svc-web \+ /etc/s6-overlay/s6-rc.d/user/contents.d/svc-workers-################# The cli builder ##############+################# The web container ##############-FROM base AS cli_builder+FROM aio_builder AS web-WORKDIR /app/apps/cli+RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/init-db-migration \+ /etc/s6-overlay/s6-rc.d/user/contents.d/svc-web++################# The workers container ##############-RUN pnpm run build+FROM aio_builder AS workers++# In the current implemtation, the workers assume the migration+# is done for them.+RUN rm /etc/s6-overlay/s6-rc.d/svc-workers/dependencies.d/init-db-migration \+ && touch /etc/s6-overlay/s6-rc.d/user/contents.d/svc-workers################# The cli ##############FROM node:21-alpine AS cliWORKDIR /app--COPY --from=cli_builder /app/apps/cli/dist/index.mjs apps/cli/index.mjs+COPY --from=base /app/apps/cli/dist/index.mjs apps/cli/index.mjsWORKDIR /app/apps/cli@@ -111,37 +131,3 @@ ARG SERVER_VERSION=nightlyENV SERVER_VERSION=${SERVER_VERSION}ENTRYPOINT ["node", "index.mjs"]---################# All-in-one ##############--# Start from the web container as its the one with the most configuration-FROM web AS aio--WORKDIR /app--ARG S6_OVERLAY_VERSION=3.2.0.0-ARG TARGETARCH--# Install s6-overlay-ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp-RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz-RUN case ${TARGETARCH} in \- "amd64") S6_ARCH=x86_64 ;; \- "arm64") S6_ARCH=aarch64 ;; \- esac \- && echo https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz -O /tmp/s6-overlay-${S6_ARCH}.tar.xz \- && wget https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz -O /tmp/s6-overlay-${S6_ARCH}.tar.xz \- && tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz \- && rm -f /tmp/s6-overlay-${S6_ARCH}.tar.xz--# Install runtime deps-RUN apk add --no-cache monolith--# Copy workers code-COPY --from=workers_builder /prod /app/apps/workers-RUN corepack enable--COPY --chmod=755 ./docker/root/etc/s6-overlay /etc/s6-overlay--ENTRYPOINT ["/init"]diff --git a/docker/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-db-migration b/docker/root/etc/s6-overlay/s6-rc.d/user/contents.d/.gitkeepsimilarity index 100%rename from docker/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-db-migrationrename to docker/root/etc/s6-overlay/s6-rc.d/user/contents.d/.gitkeepdiff --git a/docker/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-web b/docker/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-webdeleted file mode 100644index e69de29b..00000000diff --git a/docker/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-workers b/docker/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-workersdeleted file mode 100644index e69de29b..00000000