Skip to content

Commit

Permalink
build: inject secret into docker build (#648)
Browse files Browse the repository at this point in the history
* build: inject secret into docker build

* disable pr build
  • Loading branch information
gregkonush authored Dec 24, 2024
1 parent a696329 commit 46809aa
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/docker-build-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ on:
required: true
REGISTRY_TOKEN:
required: true
docker_secrets:
required: false

jobs:
build:
Expand Down Expand Up @@ -74,3 +76,5 @@ jobs:
push: true
cache-from: type=registry,ref=kalmyk.duckdns.org/lab/${{ inputs.image_name }}:latest
cache-to: type=inline
secrets: |
${{ secrets.docker_secrets }}
1 change: 1 addition & 0 deletions .github/workflows/docker-build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ jobs:
secrets:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
docker_secrets: mapbox_access_token=${{ secrets.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN }}
3 changes: 2 additions & 1 deletion apps/findbobastore/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ RUN corepack enable
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/apps/findbobastore/node_modules ./apps/findbobastore/node_modules
COPY . .
RUN pnpm build:findbobastore
RUN --mount=type=secret,id=mapbox_access_token,env=NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN \
pnpm build:findbobastore

FROM node:lts-alpine AS runner
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-findbobastore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FULL_IMAGE_NAME="${IMAGE_NAME}:${TAG}"

# Build the Docker image
echo "Building Docker image: ${FULL_IMAGE_NAME}"
docker buildx build --platform linux/arm64 -t ${FULL_IMAGE_NAME} -f ${DOCKERFILE} ${CONTEXT_PATH} --push
docker buildx build --platform linux/arm64 -t ${FULL_IMAGE_NAME} -f ${DOCKERFILE} ${CONTEXT_PATH} --push --secret id=mapbox_access_token,env=NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN

# Check if the build was successful
if [ $? -eq 0 ]; then
Expand Down

0 comments on commit 46809aa

Please sign in to comment.