diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c420cd59f..c12793c7fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -270,5 +270,9 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup Docker compatibility with Podman + run: sudo ln -sf /usr/bin/podman /usr/local/bin/docker + - name: Build BitGoJS Express Docker Image - run: podman build . + run: ./scripts/build-docker-express.sh diff --git a/Dockerfile b/Dockerfile index 9c8cc575a8..e35cfa28c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -333,11 +333,13 @@ RUN cd /var/bitgo-express && \ yarn link @bitgo/sdk-coin-zec #LINK_END -#LABEL_START -LABEL created="Thu, 04 Sep 2025 18:59:30 GMT" -LABEL version=15.0.0 -LABEL git_hash=bbdf6e60b720b25e3212f3a4c5bdc81732a505e8 -#LABEL_END +ARG BUILD_DATE +ARG VERSION +ARG GIT_HASH + +LABEL created=${BUILD_DATE} +LABEL version=${VERSION} +LABEL git_hash=${GIT_HASH} USER node ENV NODE_ENV=production diff --git a/modules/express/package.json b/modules/express/package.json index a3101af19a..d47cf6f0aa 100644 --- a/modules/express/package.json +++ b/modules/express/package.json @@ -30,8 +30,7 @@ "upload-artifacts": "node scripts/upload-test-reports.js", "start": "node bin/bitgo-express", "update-bitgo": "bash ./scripts/update-bitgo.sh", - "build-docker": "podman build -f ../../Dockerfile --platform=linux/amd64 -t bitgo/express:latest -t bitgo/express:$(jq -r .version < package.json) ../..", - "push-docker": "podman push bitgo/express:latest bitgo/express:$(jq -r .version < package.json)", + "build-docker": "cd ../../ && yarn update-dockerfile && ./scripts/build-docker-express.sh", "check-fmt": "yarn prettier --check '{src,test}/**/*.{ts,js,json}'", "unprettied": "grep -R -L --include '*.ts' --include '*.js' --include '*.json' '@prettier' src test", "fmt": "yarn prettier --write '{src,test}/**/*.{ts,js,json}'" diff --git a/package.json b/package.json index d085e72be1..f7eeca1762 100644 --- a/package.json +++ b/package.json @@ -130,8 +130,7 @@ "dev": "tsc -b ./tsconfig.packages.json -w", "prepare": "husky install", "sdk-coin:new": "yo ./scripts/sdk-coin-generator", - "build-docker-express": "yarn update-dockerfile && podman build --platform=linux/amd64 -t bitgo/express:latest -t bitgo/express:$(jq -r .version < modules/express/package.json) .", - "push-docker-express": "podman push bitgo/express:latest && podman push bitgo/express:$(jq -r .version < modules/express/package.json)", + "build-docker-express": "yarn update-dockerfile && ./scripts/build-docker-express.sh", "update-dockerfile": "tsx scripts/update-dockerfile.ts", "precommit": "lint-staged", "lint-fix": "lerna run lint --parallel -- --fix", diff --git a/scripts/build-docker-express.sh b/scripts/build-docker-express.sh new file mode 100755 index 0000000000..8d37ad9d2a --- /dev/null +++ b/scripts/build-docker-express.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +# Get dynamic build arguments +BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +VERSION=$(jq -r .version < modules/express/package.json) +GIT_HASH=$(git rev-parse HEAD) + +echo "Building Docker image with:" +echo " BUILD_DATE: $BUILD_DATE" +echo " VERSION: $VERSION" +echo " GIT_HASH: $GIT_HASH" + +# Build the Docker image +docker build \ + --platform=linux/amd64 \ + --build-arg BUILD_DATE="$BUILD_DATE" \ + --build-arg VERSION="$VERSION" \ + --build-arg GIT_HASH="$GIT_HASH" \ + -t bitgo/express:latest \ + -t bitgo/express:"$VERSION" \ + . + +echo "Docker build completed successfully!" diff --git a/scripts/update-dockerfile.ts b/scripts/update-dockerfile.ts index 3d32da8889..7d83349a36 100644 --- a/scripts/update-dockerfile.ts +++ b/scripts/update-dockerfile.ts @@ -72,15 +72,9 @@ async function updateDockerFile(lerna) { .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(/#LABEL_START((.|\n)*)#LABEL_END/, `#LABEL_START\n${labelContent}#LABEL_END`); + .replace(/#LINK_START((.|\n)*)#LINK_END/, `#LINK_START\n${linkContent}#LINK_END`); fs.writeFileSync('Dockerfile', dockerContents); }