diff --git a/.dockerignore b/.dockerignore index 6962a17c..dc3d92a0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,7 +2,6 @@ # # SPDX-License-Identifier: CC0-1.0 -.git node_modules config lib diff --git a/.github/workflows/docker-hub-develop.yml b/.github/workflows/docker-hub-develop.yml index f52a002c..173a22ab 100644 --- a/.github/workflows/docker-hub-develop.yml +++ b/.github/workflows/docker-hub-develop.yml @@ -30,8 +30,6 @@ jobs: uses: actions/checkout@v4 - name: Unshallow for git describe so we can create version.txt run: git fetch --prune --unshallow --tags --all --force - - name: Prepare version file - run: git describe > version.txt # Needed for multi platform builds - name: Set up QEMU diff --git a/.github/workflows/docker-hub-latest.yml b/.github/workflows/docker-hub-latest.yml index 48dfe4ba..cfa0af37 100644 --- a/.github/workflows/docker-hub-latest.yml +++ b/.github/workflows/docker-hub-latest.yml @@ -30,9 +30,6 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Unshallow for git describe so we can create version.txt run: git fetch --prune --unshallow --tags --all --force - - name: Prepare version file - run: git describe > version.txt - # Needed for multi platform builds - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/.github/workflows/docker-hub-release.yml b/.github/workflows/docker-hub-release.yml index 968e70d8..b19e59ee 100644 --- a/.github/workflows/docker-hub-release.yml +++ b/.github/workflows/docker-hub-release.yml @@ -30,8 +30,6 @@ jobs: run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Unshallow for git describe so we can create version.txt run: git fetch --prune --unshallow --tags --all --force - - name: Prepare version file - run: git describe > version.txt # Needed for multi platform builds - name: Set up QEMU diff --git a/Dockerfile b/Dockerfile index 8ddb8102..a5b3c8ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,19 +3,23 @@ # # SPDX-License-Identifier: Apache-2.0 AND AFL-3.0 -# We can't use alpine anymore because crypto has rust deps. -FROM node:20-slim +FROM node:20-slim as build-stage +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* COPY . /tmp/src +# describe the version. +RUN cd /tmp/src && git describe > version.txt.tmp && mv version.txt.tmp version.txt +# build and install RUN cd /tmp/src \ - && yarn install --network-timeout 100000 \ + && yarn install --frozen-lockfile --network-timeout 100000 \ && yarn build \ - && mv lib/ /draupnir/ \ - && mv node_modules / \ - && mv draupnir-entrypoint.sh / \ - && mv package.json / \ - && mv version.txt / \ - && cd / \ - && rm -rf /tmp/* + && yarn install --frozen-lockfile --production --network-timeout 100000 + +FROM node:20-slim as final-stage +COPY --from=build-stage /tmp/src/version.txt version.txt +COPY --from=build-stage /tmp/src/lib/ /draupnir/ +COPY --from=build-stage /tmp/src/node_modules /node_modules +COPY --from=build-stage /tmp/src/draupnir-entrypoint.sh / +COPY --from=build-stage /tmp/src/package.json / ENV NODE_ENV=production ENV NODE_CONFIG_DIR=/data/config