diff --git a/.drone.yml b/.drone.yml index 27416bc..aed188e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -60,51 +60,15 @@ steps: when: event: tag - - name: push image - arm - image: plugins/docker + - name: Build and publish docker images + image: thegeeklab/drone-docker-buildx settings: repo: iamthefij/minitor-go auto_tag: true - auto_tag_suffix: linux-arm - username: - from_secret: docker_username - password: - from_secret: docker_password - build_args: - - ARCH=arm - - REPO=arm32v7 - - - name: push image - arm64 - image: plugins/docker - settings: - repo: iamthefij/minitor-go - auto_tag: true - auto_tag_suffix: linux-arm64 - username: - from_secret: docker_username - password: - from_secret: docker_password - build_args: - - ARCH=arm64 - - REPO=arm64v8 - - - name: push image - amd64 - image: plugins/docker - settings: - repo: iamthefij/minitor-go - auto_tag: true - auto_tag_suffix: linux-amd64 - username: - from_secret: docker_username - password: - from_secret: docker_password - - - name: publish manifest - image: plugins/manifest - settings: - spec: manifest.tmpl - auto_tag: true - ignore_missing: true + platforms: + - linux/amd64 + - linux/arm64 + - linux/arm username: from_secret: docker_username password: diff --git a/Dockerfile b/Dockerfile index 54580af..e518292 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ -ARG REPO=library -FROM ${REPO}/alpine:3.18 +FROM alpine:3.18 RUN mkdir /app WORKDIR /app/ # Add common checking tools -RUN apk --no-cache add bash=~5 curl=~8 jq=~1 bind-tools=~9 tzdata~=2023c +RUN apk --no-cache add bash=~5 curl=~8 jq=~1 bind-tools=~9 tzdata~=2024a # Add minitor user for running as non-root RUN addgroup -S minitor && adduser -S minitor -G minitor @@ -15,8 +14,9 @@ COPY ./scripts /app/scripts RUN chmod -R 755 /app/scripts # Copy minitor in -ARG ARCH=amd64 -COPY ./dist/minitor-linux-${ARCH} ./minitor +ARG TARGETOS +ARG TARGETARCH +COPY ./dist/minitor-${TARGETOS}-${TARGETARCH} ./minitor # Drop to non-root user USER minitor diff --git a/Dockerfile.multi-stage b/Dockerfile.multi-stage index bcd4546..bd74980 100644 --- a/Dockerfile.multi-stage +++ b/Dockerfile.multi-stage @@ -1,4 +1,3 @@ -ARG REPO=library FROM golang:1.20 AS builder RUN mkdir /app @@ -9,12 +8,13 @@ RUN go mod download COPY ./*.go /app/ -ARG ARCH=amd64 +ARG TARGETOS +ARG TARGETARCH ARG VERSION=dev -ENV CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} +ENV CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=${TARGETARCH} RUN go build -ldflags "-X main.version=${VERSION}" -a -installsuffix nocgo -o minitor . -FROM ${REPO}/alpine:3.18 +FROM alpine:3.18 RUN mkdir /app WORKDIR /app/ @@ -22,7 +22,7 @@ WORKDIR /app/ COPY --from=builder /app/minitor . # Add common checking tools -RUN apk --no-cache add bash=~5 curl=~8 jq=~1 bind-tools=~9 tzdata~=2023c +RUN apk --no-cache add bash=~5 curl=~8 jq=~1 bind-tools=~9 tzdata~=2024a # Add minitor user for running as non-root RUN addgroup -S minitor && adduser -S minitor -G minitor diff --git a/Makefile b/Makefile index 19514a1..b9423e7 100644 --- a/Makefile +++ b/Makefile @@ -79,11 +79,11 @@ $(TARGET_ALIAS): # Arch specific docker build targets .PHONY: docker-build-arm docker-build-arm: dist/minitor-linux-arm - docker build --build-arg REPO=arm32v7 --build-arg ARCH=arm . -t ${DOCKER_TAG}-linux-arm + docker build --platform linux/arm . -t ${DOCKER_TAG}-linux-arm .PHONY: docker-build-arm64 docker-build-arm64: dist/minitor-linux-arm64 - docker build --build-arg REPO=arm64v8 --build-arg ARCH=arm64 . -t ${DOCKER_TAG}-linux-arm64 + docker build --platform linux/arm64 . -t ${DOCKER_TAG}-linux-arm64 # Cross run on host architechture .PHONY: docker-run-arm diff --git a/manifest.tmpl b/manifest.tmpl deleted file mode 100644 index d1e7379..0000000 --- a/manifest.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -image: iamthefij/minitor-go:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} -{{#if build.tags}} -tags: -{{#each build.tags}} - - {{this}} -{{/each}} -{{/if}} -manifests: - - - image: iamthefij/minitor-go:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 - platform: - architecture: amd64 - os: linux - - - image: iamthefij/minitor-go:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64 - platform: - architecture: arm64 - os: linux - variant: v8 - - - image: iamthefij/minitor-go:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm - platform: - architecture: arm - os: linux - variant: v7