某些版主要是不懂技术就不要把这个帖子移动到灌水区 这真的需要技术
name: Publish Docker Image
on:
push:
tags:
- 'v*'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: git
run: |
git clone https://gitee.com/openkylin/openkylin-docker.git yangtze
cp Dockerfile yangtze/Dockerfile
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: zhangyiming748/yangtze
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: |
linux/amd64
# linux/arm64
由于原始代码给的方案会造成无密码 也无法更改密码 这里做了一些修改
# 基于空镜像scratch
FROM scratch
LABEL maintainer="zen <zhangyiming748@gmail.com>"
LABEL version="1.0"
LABEL description="This is a custom image based on scratch"
# 添加rootfs文件到镜像中
ADD ./yangtze/yangtze-rootfs.tar.gz /
# 安装curl和vim
# RUN apt-get update && apt-get install -y curl vim git neofetch
# 创建一个用户
RUN adduser zen && echo "zen:123456" | chpasswd
# 用户加入到sudo
RUN adduser zen sudo
# 切换到用户目录
WORKDIR /home/zen
# 设置容器启动时的默认命令,并切换到xxx
USER zen
CMD ["/bin/bash"]
添加我为好友,拉您入交流群!
请使用微信扫一扫!