Hi I am trying to create an image of a simple project holded on github and push it to docker hub, but I do not achieve it.
this is my .yml file:
name: workflow 3
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Set up QEMU
uses: docker/setup-qemu-action#v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action#v1
- name: login to docker hub
uses: docker/login-action#v1
with:
username: ${{ secrets.DOCKER_NAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push
uses: docker/build-push-action#v2
with:
context: .
push: true
tags: user/app:latest
but I receive this error: Error: buildx failed with: error: failed to solve: failed to read dockerfile: open /tmp/buildkit-mount2002185417/Dockerfile: no such file or directory
Related
I'm getting this error:
error: failed to solve: error writing layer blob: server message: insufficient_scope: authorization failed
after this GitHub Action finishes building the Docker image:
# https://docs.docker.com/ci-cd/github-actions/
name: Publish Docker Image
on:
workflow_dispatch:
push:
branches:
- master
paths:
- "Dockerfile"
schedule:
- cron: "0 6 * * */3"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout#v3
- name: Set up QEMU
uses: docker/setup-qemu-action#v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action#v1
- name: Login to Docker Hub
uses: docker/login-action#v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push
uses: docker/build-push-action#v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ghcr.io/t145/black-mirror:latest
cache-from: type=registry,ref=t145/black-mirror:buildcache
cache-to: type=registry,ref=t145/black-mirror:buildcache,mode=max
It's configured following the guide linked at the top of the document. Why would this error occur here?
Try updating the cache-from and cache-to cache references to ghcr.io/t145/black-mirror. When you omit the registry (ghcr.io), I believe it defaults to DockerHub.
I want to build my image and push it to dockerhub using github actions.This is my repo
And this is how I want to do my job:
name: ci
on:
push:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout#v2
-
name: Set up QEMU
uses: docker/setup-qemu-action#v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action#v1
-
name: Login to DockerHub
uses: docker/login-action#v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action#v2
with:
context: .
load: true
tags: shirzadi/ehsan:latest
-
name: Push it!
run: docker push ${{ env.IMAGE }}:${{ env.GIT_SHA }}
And this is the result:
You are using environment variables that don't exist. According to docker/build-push-action#v2 documentation it can build, tag and push your image in a single step:
jobs:
docker:
steps:
# ...
-
name: Build and push
uses: docker/build-push-action#v2
with:
context: .
push: true
tags: shirzadi/ehsan:latest,shirzadi/ehsan:${{ env.GITHUB_SHA }}
The tags key lists 2 tags and use the GITHUB_SHA environment variable. These tags will be pushed as the push key is set to true.
See:
Github Actions - Default environment variables
docker/build-push-action#v2 - customizing inputs
You are not having env.IMAGE data. Below piece of code should do the job.
- name: Build and push
run: docker build -t ${{ env.IMAGE }}:${{ github.sha }} .
env:
IMAGE: shirzadi/ehsan
- name: Push it!
run: docker push ${{ env.IMAGE }}:${{ github.sha }}
env:
IMAGE: shirzadi/ehsan
I'm trying to create a workflow that builds and pushes a docker image to the docker hub using https://github.com/docker/build-push-action.
I have a monorepo with a folder structure like this:
project
api
Dockerfile
client
and this is the workflow:
name: deploy
on:
push:
branches:
- main
paths:
- "api/**"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action#v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action#v1
- name: Login to DockerHub
uses: docker/login-action#v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action#v2
with:
push: true
tags: repo/kheilyshad-api:latest
context: .
file: api/Dockerfile
it always fails with this error:
/usr/bin/docker buildx build --tag ***/kheilyshad-api:latest --iidfile /tmp/docker-build-push-yGQ2mf/iidfile --metadata-file /tmp/docker-build-push-yGQ2mf/metadata-file --file api/Dockerfile --push .
error: could not find api: stat api: no such file or directory
Error: buildx failed with: error: could not find api: stat api: no such file or directory
I have to build the docker image in the root so I use file to specify the path to Dockerfile. it's basically like this
docker build -f ./api/Dockerfile .
but it couldn't find the api folder. I tried to set the file to ./api/Dockerfile, api, etc. but none of them work.
Seems like you're not checking out the repo. Try to add actions/checkout#v2 to your steps:
steps:
- uses: actions/checkout#v2
Since the FROM syntax in dockerfile doesnt support a github repo link.
There are few Dockerfiles in github repo.
How could I use github action to build them and push to docker-registry once per day?
you can use this example:
name: ci
on:
push:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout#v2
-
name: Set up QEMU
uses: docker/setup-qemu-action#v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action#v1
-
name: Login to DockerHub
uses: docker/login-action#v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action#v2
with:
context: .
push: true
tags: user/app:latest
I'm new to Docker and trying to perform CI using GitHub Actions.
Here's my .yml file on GitHub.
name: CI to Docker Hub
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout#v2
- name: Login to Docker Hub
uses: docker/login-action#v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action#v1
- name: Build and push
id: docker_build
uses: docker/build-push-action#v2
with:
context: .
file: ./Dockerfile
push: true
tags: your-order-backend:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
I have added Secrets in my Github too of Docker Hub.
I'm not sure why, but it is failing at > exporting to image:
It is resloved!
In my case, there was no repo in the Docker Hub created whose tag I have passed here in the yml file.
I created the repo and it worked
for me I fixed it by changing "push: true" to "load: true"
In my case, Id needed to create the repo in dockerhub as in the response of Sagar, but the problem still were there. I'd recognized I was passing the tags incorrectly, fix it and the problem was gone. (You can See the official examples)
Before:
tags: ${{ github.sha }}, latest
After (correctly):
tags: |
henriqueholtz/fullcycle-gitops:${{ github.sha }}
henriqueholtz/fullcycle-gitops:latest