[DEPRECATED] Go implementation of plcbundle

update docker build

+72
.tangled/workflows/docker-release.yml
··· 1 + # .tangled/workflows/docker-release.yml 2 + 3 + when: 4 + - event: ["push"] 5 + branch: ["refs/tags/*"] # Trigger on any tag push 6 + - event: ["manual"] 7 + branch: ["main"] # Allow manual trigger from main 8 + 9 + engine: "nixery" 10 + 11 + dependencies: 12 + nixpkgs: 13 + - docker 14 + - git 15 + - bash 16 + 17 + environment: 18 + DOCKER_REGISTRY: "docker.io" 19 + DOCKER_IMAGE: "atscan/plcbundle" 20 + 21 + steps: 22 + - name: "Extract version info" 23 + command: | 24 + # Extract version from tag or git 25 + if [[ "${TANGLED_REF}" =~ ^refs/tags/(.+)$ ]]; then 26 + VERSION="${BASH_REMATCH[1]}" 27 + else 28 + VERSION=$(git describe --tags --always --dirty) 29 + fi 30 + 31 + GIT_COMMIT=$(git rev-parse --short HEAD) 32 + BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") 33 + 34 + echo "VERSION=${VERSION}" >> $TANGLED_ENV 35 + echo "GIT_COMMIT=${GIT_COMMIT}" >> $TANGLED_ENV 36 + echo "BUILD_DATE=${BUILD_DATE}" >> $TANGLED_ENV 37 + 38 + echo "Building version: ${VERSION}" 39 + echo "Commit: ${GIT_COMMIT}" 40 + echo "Date: ${BUILD_DATE}" 41 + 42 + - name: "Set up Docker Buildx" 43 + command: | 44 + docker buildx create --use --name multiarch --driver docker-container 45 + docker buildx inspect --bootstrap 46 + 47 + - name: "Login to Docker Hub" 48 + command: | 49 + echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin 50 + environment: 51 + DOCKER_USERNAME: "${{ secrets.DOCKER_USERNAME }}" 52 + DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}" 53 + 54 + - name: "Build and push multi-platform images" 55 + command: | 56 + docker buildx build \ 57 + --platform linux/amd64,linux/arm64 \ 58 + --build-arg VERSION="${VERSION}" \ 59 + --build-arg GIT_COMMIT="${GIT_COMMIT}" \ 60 + --build-arg BUILD_DATE="${BUILD_DATE}" \ 61 + --tag ${DOCKER_IMAGE}:${VERSION} \ 62 + --tag ${DOCKER_IMAGE}:latest \ 63 + --push \ 64 + . 65 + 66 + echo "✓ Pushed ${DOCKER_IMAGE}:${VERSION}" 67 + echo "✓ Pushed ${DOCKER_IMAGE}:latest" 68 + 69 + - name: "Verify images" 70 + command: | 71 + echo "Verifying pushed images..." 72 + docker buildx imagetools inspect ${DOCKER_IMAGE}:${VERSION}
-27
.tangled/workflows/release.yml
··· 1 - when: 2 - - event: ["manual"] 3 - branch: ["main"] 4 - 5 - engine: "nixery" 6 - 7 - clone: 8 - depth: 0 9 - 10 - dependencies: 11 - nixpkgs: 12 - - go 13 - - goreleaser 14 - - gcc 15 - - git 16 - - zstd 17 - - zstd.dev 18 - 19 - environment: 20 - CGO_ENABLED: "1" 21 - 22 - steps: 23 - - name: "Build with GoReleaser" 24 - command: | 25 - goreleaser build --clean 26 - echo "✓ Binaries built:" 27 - ls -lh dist/*/plcbundle
+5 -1
Dockerfile
··· 11 11 12 12 COPY . . 13 13 14 + ARG VERSION=dev 15 + ARG GIT_COMMIT=unknown 16 + ARG BUILD_DATE=unknown 17 + 14 18 RUN CGO_ENABLED=1 go build \ 15 - -ldflags="-w -s" \ 19 + -ldflags="-w -s -X 'main.version=${VERSION}' -X 'main.gitCommit=${GIT_COMMIT}' -X 'main.buildDate=${BUILD_DATE}'" \ 16 20 -trimpath \ 17 21 -o plcbundle \ 18 22 ./cmd/plcbundle
-19
Dockerfile.goreleaser
··· 1 - # syntax=docker/dockerfile:1 2 - 3 - FROM alpine:3.19 4 - 5 - RUN apk add --no-cache ca-certificates zstd-libs 6 - 7 - RUN addgroup -g 1000 plcbundle && \ 8 - adduser -D -u 1000 -G plcbundle plcbundle && \ 9 - mkdir -p /data && \ 10 - chown plcbundle:plcbundle /data 11 - 12 - # GoReleaser puts binaries in $TARGETPLATFORM/ 13 - ARG TARGETPLATFORM 14 - COPY ${TARGETPLATFORM}/plcbundle /usr/local/bin/plcbundle 15 - 16 - WORKDIR /data 17 - USER plcbundle 18 - 19 - ENTRYPOINT ["plcbundle"]
+1 -18
Makefile
··· 98 98 @echo "Bumping major version..." 99 99 @./scripts/bump-version.sh major 100 100 101 - # Build release binaries with GoReleaser (local test) 102 - release-build: 103 - @echo "Building release binaries with GoReleaser..." 104 - @goreleaser build --snapshot --clean 105 - @echo "✓ Binaries built in dist/" 106 - 107 - # Create release (runs your script + GoReleaser) 101 + # Create release 108 102 release: 109 103 @echo "Creating release for version $(VERSION)..." 110 104 @./scripts/release.sh 111 - 112 - # Full release with binaries 113 - release-full: release release-publish 114 - 115 - # Publish release with GoReleaser 116 - release-publish: 117 - @echo "Publishing release with GoReleaser..." 118 - @goreleaser release --clean 119 105 120 106 # ============================================================================ 121 107 # Docker Commands ··· 204 190 @echo " make bump-minor - Bump minor (0.1.0 -> 0.2.0)" 205 191 @echo " make bump-major - Bump major (0.1.0 -> 1.0.0)" 206 192 @echo " make release - Push tag to trigger release" 207 - @echo " make release-build - Test build all platforms locally" 208 - @echo " make release-publish- Publish with GoReleaser" 209 - @echo " make release-full - Complete release (tag + binaries)" 210 193 @echo "" 211 194 @echo "Docker:" 212 195 @echo " make docker-build - Build image (current platform)"