From dbc6bfef6e804e272cf0fc133c911496afc438a0 Mon Sep 17 00:00:00 2001 From: wukko Date: Sun, 9 Apr 2023 09:23:16 +0600 Subject: [PATCH] trying to get .git inside the container on hop --- Dockerfile | 7 +++++-- src/modules/sub/currentCommit.js | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 19cdaccc..9f164278 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,12 @@ FROM node:18-bullseye-slim WORKDIR /app COPY package*.json ./ -COPY .git ./ -RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* +ARG GIT_COMMIT +RUN apt-get update +RUN apt-get install -y git +RUN rm -rf /var/lib/apt/lists/* RUN npm install +RUN git clone -n https://github.com/wukko/cobalt.git --depth 1 && cd cobalt && git checkout ${GIT_COMMIT} ./ COPY . . EXPOSE 9000 CMD [ "node", "src/cobalt" ] diff --git a/src/modules/sub/currentCommit.js b/src/modules/sub/currentCommit.js index f3c145f5..7f44c1b4 100644 --- a/src/modules/sub/currentCommit.js +++ b/src/modules/sub/currentCommit.js @@ -4,6 +4,7 @@ let commit, commitInfo, branch; export function shortCommit() { if (commit) return commit; + if (process.env.GIT_COMMIT) return process.env.GIT_COMMIT; let c = execSync('git rev-parse --short HEAD').toString().trim(); commit = c; return c @@ -17,6 +18,7 @@ export function getCommitInfo() { } export function getCurrentBranch() { if (branch) return branch; + if (process.env.GIT_BRANCH) return process.env.GIT_BRANCH; let b = execSync('git branch --show-current').toString().trim(); branch = b; return b