Some checks failed
Docker Build / Build and push docker image (push) Failing after 31s
109 lines
2.9 KiB
YAML
109 lines
2.9 KiB
YAML
name: Docker Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
REGISTRY_USERNAME: admin
|
|
REGISTRY_PASSWORD: 6nkTT9Th5z6gR?ro
|
|
IMAGE_REGISTRY: hub.docker.xiaohei.one
|
|
PROJECT_NAME: test-devops
|
|
IMAGE_TAGS: ${{ gitea.sha }}
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and push docker image
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
# - name: install sysbox dependency
|
|
# run: |
|
|
# apt update
|
|
# apt upgrade -y
|
|
# curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
# apt install nodejs -y
|
|
# node --version
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
# - name: Build and Push
|
|
# uses: docker://gcr.io/kaniko-project/executor:latest
|
|
# with:
|
|
# context: .
|
|
# dockerfile: Dockerfile
|
|
# destination: test-devops:0.0.1
|
|
# registry: ${{ IMAGE_REGISTRY }}
|
|
# username: ${{ REGISTRY_USERNAME }}
|
|
# password: ${{ REGISTRY_PASSWORD }}
|
|
|
|
- name: Log in to Container Registry
|
|
run: echo ${{ env.REGISTRY_PASSWORD }}
|
|
|
|
|
|
# - name: Build and Push Docker image
|
|
# run: |
|
|
# docker run \
|
|
# -v $(pwd):/workspace \
|
|
# -v /kaniko/.docker:/kaniko/.docker \
|
|
# -e DOCKER_CONFIG=/kaniko/.docker \
|
|
# gcr.io/kaniko-project/executor:latest \
|
|
# --context=dir:///workspace \
|
|
# --dockerfile=/workspace/Dockerfile \
|
|
# --destination=${{ IMAGE_REGISTRY }}/test-devops:0.0.1
|
|
# env:
|
|
# DOCKER_CONFIG: /kaniko/.docker
|
|
# IMAGE_REGISTRY: ${{ IMAGE_REGISTRY }}
|
|
# REGISTRY_USERNAME: ${{ REGISTRY_USERNAME }}
|
|
# REGISTRY_PASSWORD: ${{ REGISTRY_PASSWORD }}
|
|
|
|
|
|
- name: install podman
|
|
run: |
|
|
apt update
|
|
apt install podman -y
|
|
apt install buildah
|
|
|
|
# - name: 创建非特权用户
|
|
# run: |
|
|
# # 2. 创建用户 (如果需要)
|
|
# adduser podmanuser
|
|
|
|
# # 3. 配置 subuid/subgid
|
|
# echo "podmanuser:100000:65536" >> /etc/subuid
|
|
# echo "podmanuser:100000:65536" >> /etc/subgid
|
|
|
|
# # 4. 切换到非 root 用户
|
|
# su - podmanuser
|
|
|
|
- uses: redhat-actions/buildah-build@v2
|
|
with:
|
|
image: my-new-image
|
|
tags: v1 ${{ gitea.sha }}
|
|
dockerfiles: |
|
|
./Dockerfile
|
|
|
|
|
|
|
|
|
|
# - name: Print to Log
|
|
# id: print-to-log
|
|
# uses: ./
|
|
# with:
|
|
# who-to-greet: Test
|
|
|
|
|
|
|
|
# - name: Build Docker Image
|
|
# run: podman build -t ${{ IMAGE_REGISTRY }}/${{ PROJECT_NAME }}:${{ IMAGE_TAGS }} .
|
|
|
|
# - name: login to registry
|
|
# run: podman login ${{ IMAGE_REGISTRY }} -u ${{ REGISTRY_USER }} -p ${{ REGISTRY_PASSWORD }}
|
|
|
|
# - name: push to registry
|
|
# run: podman push ${{ IMAGE_REGISTRY }}/${{ PROJECT_NAME }}:${{ IMAGE_TAGS }} |