Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions .github/workflows/etcdcluster.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,53 @@
name: etcdcluster

permissions:
contents: read

on:
push:
branches: [ etcdcluster ]
workflow_dispatch:

inputs:
branch:
description: 'branch'
required: true
default: 'main'
tag:
description: 'image tag'
required: false
default: ''
env:
REPO: yylt/etcdauto
PROJECT: etcdauto
BRANCH: main
Dockerfile: Dockerfile-etcdcluster
REGISTRY_NAME: "docker.io"
REGISTRY_USER: "${{ secrets.DOCKER_HUB_USER }}"
REGISTRY_PASS: "${{ secrets.DOCKER_HUB_PASSWORD }}"
REGISTRY_NAME: "${{ secrets.MY_HUB_NAME }}"
REGISTRY_USER: "${{ secrets.MY_HUB_USER }}"
REGISTRY_PASS: "${{ secrets.MY_HUB_PASSWORD }}"
BUILDX_NO_DEFAULT_ATTESTATIONS: 1

jobs:
build:
name: Build
runs-on: ubuntu-latest #[self-hosted, linux, x64]
steps:

- name: Getting image tag
id: tag
run: |
echo "trigger by ${{ github.event_name }}"
echo "sha256 is ${{ github.sha }}"

if ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "vbranch=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
if [ "${{ github.event.inputs.tag }}" != "" ] ; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "tag=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
fi
else
echo "vbranch=${{ env.BRANCH }}" >> $GITHUB_ENV
echo "tag=${{ env.BRANCH }}" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Login to Registry
Expand All @@ -28,13 +57,19 @@ jobs:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASS }}

- name: Check out build code
uses: actions/checkout@v4
with:
repository: ${{ env.REPO }}
ref: ${{ env.vbranch }}
path: ${{ env.PROJECT }}

- name: Docker Image Build And Push
run: |
cd ${{ env.PROJECT }}
docker buildx build --no-cache \
--platform linux/amd64,linux/arm64 \
--provenance false --sbom false \
--output "type=image,push=true" \
--tag ${{ env.REGISTRY_NAME }}/yylt/etcdcluster:${{ env.date }} \
--tag ${{ env.REGISTRY_NAME }}/yylt/etcdcluster:latest \
--file ./${{ env.Dockerfile }} .

--tag ${{ env.REGISTRY_NAME }}/multiarch/etcdcluster:${{ env.tag }} \
--file ../${{ env.Dockerfile }} .
22 changes: 15 additions & 7 deletions Dockerfile-etcdcluster
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
ARG ETCD_IMAGE=gcr.io/etcd-development/etcd:v3.5.21
# syntax = docker/dockerfile:1.4
ARG ETCD_IMAGE=gcr.io/etcd-development/etcd:v3.5.26

FROM --platform=$BUILDPLATFORM golang:1.25-trixie AS builder
FROM --platform=$BUILDPLATFORM golang:1.25 AS builder

ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM

WORKDIR /

COPY source source
COPY . .

RUN GOARCH=${TARGETARCH} make -C /source/etcdcluster build
ENV GOARCH=${TARGETARCH}

RUN BUILD_PLATFORMS=${TARGETPLATFORM} make build

FROM ${ETCD_IMAGE} as ETCD

FROM debian:13-slim
FROM debian:12-slim

ARG TARGETPLATFORM

USER root

COPY --from=builder /source/etcdcluster/bin/${TARGETPLATFORM}/etcdcluster /usr/bin/
COPY --from=builder /bin/${TARGETPLATFORM}/etcdcluster /usr/bin/
COPY --from=builder /bin/${TARGETPLATFORM}/ecsnode /usr/bin/

COPY --from=ETCD /usr/local/bin/etcd /usr/bin/
COPY --from=ETCD /usr/local/bin/etcdctl /usr/bin/

RUN apt-get update && \
apt-get install -y --no-install-recommends golang-cfssl && \
apt-get install -y --no-install-recommends golang-cfssl dumb-init iproute2 curl && \
rm -rf /var/lib/apt/lists/*

USER 65532:65532
ENTRYPOINT ["etcdcluster"]