Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ RUN cd /var/bitgo-express && \
yarn link @bitgo/sdk-coin-zec
#LINK_END

#LABEL_START
LABEL created="Mon, 18 Jul 2022 20:03:36 GMT"
LABEL version=9.12.0
LABEL git_hash=973a8b01131f5958dd5b588a17dc4346b148acb3
#LABEL_END

USER node
ENV NODE_ENV production
ENV BITGO_BIND 0.0.0.0
Expand Down
18 changes: 12 additions & 6 deletions scripts/update-dockerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ type ManagedModule = {

/**
* Create a function which can run lerna commands
* @param lernaPath {string} path to lerna binary
* @param {String} lernaPath - path to lerna binary
* @returns {function(string, string[], Object.<string, string>): Promise<string>}
*/
function getLernaRunner(lernaPath) {
return async (command, args = [], options = {}) => {
function getLernaRunner(lernaPath: string) {
return async (command: string, args: string[] = [], options = {}) => {
const { stdout } = await execa(
lernaPath,
[command, ...args],
Expand All @@ -36,7 +36,7 @@ const walkDependencies = (packageName: string, setDeps: Set<ManagedModule>, grap

/**
* Get information on the modules in this repo that are managed by lerna.
* @param lerna {function}
* @param {Function} lerna
* @returns {Promise<{path: *, name: *, deps: *, version: *}[]>}
*/
async function updateDockerFile(lerna) {
Expand All @@ -56,10 +56,16 @@ async function updateDockerFile(lerna) {

const linkers = Array.from(setDeps).map((dep) => ` yarn link ${dep.name}`).join(' && \\\n');
const linkContent = `RUN cd /var/bitgo-express && \\\n${linkers}\n`;

// add metadata about the build to docker labels
let labelContent = `LABEL created="${new Date().toUTCString()}"\n`; // add created timestamp;
labelContent += `LABEL version=${require('../modules/express/package.json').version}\n`; // set current image version from express
labelContent += `LABEL git_hash=${require('child_process').execSync(`git rev-parse HEAD`).toString().trim()}\n`; // set to latest git HEAD hash

dockerContents = dockerContents
.replace(/#COPY_START((.|\n)*)#COPY_END/, `#COPY_START\n${copyContent}#COPY_END`)
.replace(/#LINK_START((.|\n)*)#LINK_END/, `#LINK_START\n${linkContent}#LINK_END`);

.replace(/#LINK_START((.|\n)*)#LINK_END/, `#LINK_START\n${linkContent}#LINK_END`)
.replace(/#LABEL_START((.|\n)*)#LABEL_END/, `#LABEL_START\n${labelContent}#LABEL_END`);

fs.writeFileSync('Dockerfile', dockerContents);
}
Expand Down