From 290f98ae8b51755d1c9b6b48422a7f556a5e5de1 Mon Sep 17 00:00:00 2001 From: sup39 Date: Thu, 2 Nov 2023 18:38:03 +0900 Subject: [PATCH] chore: append `+neko:xxx` to version in docker image --- .dockerignore | 2 ++ Dockerfile | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/.dockerignore b/.dockerignore index ad6ad169a..ac4ce35b0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -40,5 +40,7 @@ packages/backend/assets/instance.css # dockerignore custom .git +!.git/HEAD +!.git/refs Dockerfile docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 1b94fc9b4..c38603ed8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,11 @@ RUN pnpm run --filter native-utils build # Copy in the rest of the files to compile COPY . ./ +# Create dummy .git/objects directory for `git rev-parse` +RUN mkdir .git/objects +# Write version info +RUN bash -c 'NEW_COMMIT=$(git rev-parse --short HEAD) && sed -i -r "s/\"version\": \"([^+]+).*\",$/\"version\": \"\\1+neko:${NEW_COMMIT:0:7}\",/" package.json' +# Compile RUN env NODE_ENV=production sh -c "pnpm run --filter '!native-utils' build && pnpm run gulp" # Trim down the dependencies to only those for production @@ -55,6 +60,8 @@ WORKDIR /firefish RUN apt-get update && apt-get install -y libvips-dev zip unzip tini ffmpeg COPY . ./ +# Remove .git +RUN rm -rf .git COPY --from=build /firefish/packages/megalodon /firefish/packages/megalodon