trying to get .git inside the container on hop

This commit is contained in:
wukko 2023-04-09 09:23:16 +06:00
parent db461fdd9f
commit dbc6bfef6e
2 changed files with 7 additions and 2 deletions

View file

@ -1,9 +1,12 @@
FROM node:18-bullseye-slim FROM node:18-bullseye-slim
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
COPY .git ./ ARG GIT_COMMIT
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* RUN apt-get update
RUN apt-get install -y git
RUN rm -rf /var/lib/apt/lists/*
RUN npm install RUN npm install
RUN git clone -n https://github.com/wukko/cobalt.git --depth 1 && cd cobalt && git checkout ${GIT_COMMIT} ./
COPY . . COPY . .
EXPOSE 9000 EXPOSE 9000
CMD [ "node", "src/cobalt" ] CMD [ "node", "src/cobalt" ]

View file

@ -4,6 +4,7 @@ let commit, commitInfo, branch;
export function shortCommit() { export function shortCommit() {
if (commit) return commit; if (commit) return commit;
if (process.env.GIT_COMMIT) return process.env.GIT_COMMIT;
let c = execSync('git rev-parse --short HEAD').toString().trim(); let c = execSync('git rev-parse --short HEAD').toString().trim();
commit = c; commit = c;
return c return c
@ -17,6 +18,7 @@ export function getCommitInfo() {
} }
export function getCurrentBranch() { export function getCurrentBranch() {
if (branch) return branch; if (branch) return branch;
if (process.env.GIT_BRANCH) return process.env.GIT_BRANCH;
let b = execSync('git branch --show-current').toString().trim(); let b = execSync('git branch --show-current').toString().trim();
branch = b; branch = b;
return b return b