Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Add VERSION and BUILD_NUMBER args (#261)
Browse files Browse the repository at this point in the history
- The provided docker image now requires a `VERSION` and `BUILD_NUMBER` to be set. These are provided as build arguments to the image – https://docs.docker.com/engine/reference/builder/#arg
- The `BUILD_NUMBER` will be the first seven characters of the commit hash that triggered the build.
- The `VERSION` will be the `ref_name` of the commit that triggered the build. For a branch, that will be the branch name (e.g.: `main`) and for a release it will be the release tag.
  • Loading branch information
fmrsabino authored Dec 4, 2023
1 parent 078a307 commit d301b24
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
BUILD_NUMBER=${{ github.sha }}
echo "BUILD_NUMBER=${BUILD_NUMBER::7}" >> "$GITHUB_ENV"
- uses: docker/setup-qemu-action@v3.0.0
with:
platforms: arm64
Expand All @@ -73,6 +76,9 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
BUILD_NUMBER=${{ env.BUILD_NUMBER }}
VERSION=${{ github.ref_name }}
tags: ${{ env.DOCKER_IMAGE_TAG }}
# Use inline cache storage https://docs.docker.com/build/cache/backends/inline/
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_TAG }}
Expand All @@ -84,6 +90,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
BUILD_NUMBER=${{ github.sha }}
echo "BUILD_NUMBER=${BUILD_NUMBER::7}" >> "$GITHUB_ENV"
- uses: docker/setup-qemu-action@v3.0.0
with:
platforms: arm64
Expand All @@ -96,6 +105,9 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
push: true
build-args: |
BUILD_NUMBER=${{ env.BUILD_NUMBER }}
VERSION=${{ github.ref_name }}
tags: |
safeglobal/safe-gelato-relay-service:${{ github.event.release.tag_name }}
safeglobal/safe-gelato-relay-service:latest
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ RUN yarn run build
#
FROM node:18-alpine as production
USER node

ARG VERSION
ARG BUILD_NUMBER

ENV APPLICATION_VERSION=${VERSION} \
APPLICATION_BUILD_NUMBER=${BUILD_NUMBER}

COPY --chown=node:node --from=base /app/node_modules ./node_modules
COPY --chown=node:node --from=base /app/dist ./dist
CMD [ "node", "dist/main.js" ]
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "safe-gelato-relay-service",
"version": "0.14.0",
"description": "",
"author": "",
"private": true,
Expand Down
2 changes: 2 additions & 0 deletions src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const API_KEYS: Record<SupportedChainId, string | undefined> = {
export default () => ({
about: {
name: 'safe-gelato-relay-service',
version: process.env.APPLICATION_VERSION,
buildNumber: process.env.APPLICATION_BUILD_NUMBER,
},
applicationPort: process.env.APPLICATION_PORT || '3000',
redis: {
Expand Down

0 comments on commit d301b24

Please sign in to comment.