nx-tools
nx-tools copied to clipboard
Docker images don't push to the GitHub registry
I've been trying to push my images to GitHub registry. I have no-monorepo with two projects Example of my project target inside project.json
"container": {
"executor": "@nx-tools/nx-container:build",
"options": {
"file": "apps/vyzl-frontend/frontend.Dockerfile",
"engine": "docker",
"metadata": {
"images": [
"frontend"
],
"load": true,
"tags": [
"type=ref,event=branch",
"type=ref,event=tag",
"type=ref,event=pr",
"type=semver,pattern={{version}}",
"type=semver,pattern={{major}}.{{minor}}",
"type=semver,pattern={{major}}",
"type=sha,prefix=sha-",
"ghcr.io/"organization-name"/vyzlFrontend:latest",
"ghcr.io/"organization-name"vyzlFrontend:v1"
]
}
}
},```
Hi... Change load: true for push: true 😃
Hi... Change
load: true forpush: true` 😃
Thank you, but I am faced with the following problem
> NX buildx failed with: ERROR: failed to solve: failed to push backend:main: server message: insufficient_scope: authorization failed
example of my GitHub action
name: Node.js Package
on:
push:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v3
name: Checkout
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Install Dependencies'
run: yarn install
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/vyzl
tags: |
type=semver,pattern={{version}}
type=raw,value=latest
type=sha,prefix=sha-
- name: 'nx build'
env:
INPUT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: INPUT_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} npx nx run-many --target=container,containerWorker --projects=vyzl-backend,vyzl-frontend
But I successfully login into GitHub
UPD: project targets the same, but I add push: true
You configured the imagename wrong, you are pushing to Docker Hub without authorization to a scope you have no access to. Also the latest and v1 tags are wrong, besides latest is handled automatically.
"container": {
"executor": "@nx-tools/nx-container:build",
"options": {
"file": "apps/vyzl-frontend/frontend.Dockerfile",
"engine": "docker",
"metadata": {
"images": [
"ghcr.io/ncado/vyzlFrontend"
],
"load": true,
"tags": [
"type=ref,event=branch",
"type=ref,event=tag",
"type=ref,event=pr",
"type=semver,pattern={{version}}",
"type=semver,pattern={{major}}.{{minor}}",
"type=semver,pattern={{major}}",
"type=sha,prefix=sha-",
"type=semver,pattern=v{{major}}",
]
}
}
},