Files
Draupnir/Dockerfile
Catalan Lover 9902993b6c
Some checks failed
GHCR - Development Branches / ghcr-publish (push) Failing after 39s
Docker Hub - Develop / docker-latest (push) Failing after 40s
Tests / Application Service Integration tests (push) Failing after 13m52s
Tests / Integration tests (push) Failing after 13m54s
Tests / Unit tests (push) Failing after 13m57s
Tests / Build & Lint (push) Failing after 13m59s
Implement Caching for the CI (#1055)
* Update Dockerignore

Updates dockerignore to protect against cache contamination so we can more effectively utilise the full potential of our Cache system.

* Implement Caching strategy support in dockerfile

* Implement Caching for CI to massively speed up warm builds

* Fix Wildcard funkyness breaking docker builds.

* Fix FROM AS style guideline violations

There's a style guideline that says you shouldn't mix the case of FROM and AS in a FROM AS statement. So we fix this violation in this commit.

You can also force it all to lowercase but considering all our other keywords are uppercase why not go uppercase only for consistency.
2026-03-25 16:18:18 +00:00

47 lines
1.7 KiB
Docker

# Copyright 2024 Gnuxie <Gnuxie@protonmail.com>
# Copyright 2019 The Matrix.org Foundation C.I.C.
#
# SPDX-License-Identifier: Apache-2.0 AND AFL-3.0
# syntax=docker/dockerfile:1.7
FROM node:24-slim AS build-stage
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update \
&& apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp/src
COPY package.json package-lock.json ./
COPY packages/interface-manager/package.json ./packages/interface-manager/package.json
COPY packages/matrix-basic-types/package.json ./packages/matrix-basic-types/package.json
COPY packages/matrix-protection-suite/package.json ./packages/matrix-protection-suite/package.json
COPY packages/matrix-protection-suite-for-matrix-bot-sdk/package.json ./packages/matrix-protection-suite-for-matrix-bot-sdk/package.json
COPY packages/mps-interface-adaptor/package.json ./packages/mps-interface-adaptor/package.json
COPY packages/tsconfig/package.json ./packages/tsconfig/package.json
COPY apps/draupnir/package.json ./apps/draupnir/package.json
# Install dependencies first so source edits don't invalidate this layer.
RUN --mount=type=cache,target=/root/.npm npm ci
COPY . .
# build and install
RUN npm run build \
&& npm prune --production
FROM node:24-slim AS final-stage
COPY --from=build-stage /tmp/src/apps/draupnir /apps/draupnir
COPY --from=build-stage /tmp/src/packages /packages
COPY --from=build-stage /tmp/src/node_modules /node_modules
COPY --from=build-stage /tmp/src/draupnir-entrypoint.sh /
ENV NODE_ENV=production
ENV NODE_CONFIG_DIR=/data/config
# Set SQLite's temporary directory. See #746 for context.
ENV SQLITE_TMPDIR=/data
CMD ["bot"]
ENTRYPOINT ["./draupnir-entrypoint.sh"]
VOLUME ["/data"]