diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94b3e6f..b37096e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,87 +1,31 @@ -# Credit -> https://stackoverflow.com/questions/58600986/gitlab-ci-trying-to-use-docker-buildx-to-build-for-arm64 +image: egon0/docker-with-buildx-and-git:latest -stages: - - buildx - - deploy - - Weekly buildx - - Weekly deploy +variables: + DOCKER_HOST: tcp://docker:2375/ + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" -# ----- Ad hoc Builds ----- +services: + - docker:dind -buildx: - image: docker:19.03-git - stage: buildx +build: + stage: build variables: - GIT_STRATEGY: none - artifacts: - paths: - - buildx - expire_in: 3 hour - services: - - docker:19.03-dind + IMAGE_TAG: $CI_REGISTRY_IMAGE + D_IMAGE_TAG: egon0/minio-multiarch + D_LATEST_TAG: egon0/minio-multiarch:latest script: - - export DOCKER_BUILDKIT=1 - - git clone git://github.com/docker/buildx ./docker-buildx - - docker build --platform=local -o . ./docker-buildx - only: - changes: - - Dockerfile - - .gitlab-ci.yml + - > + apk add --no-cache jq; + LATEST_MINIO_GITHUB=$(wget --quiet "https://api.github.com/repos/minio/minio/releases/latest" -O - | jq -r '.tag_name'); + LATEST_MINIO_DHUB=$(wget -q https://registry.hub.docker.com/v1/repositories/egon0/minio-multiarch/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | tail -n1); + if [ "$LATEST_MINIO_GITHUB" != "$LATEST_MINIO_DHUB" ] + then + docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD + docker buildx create --use --name A$CI_COMMIT_SHORT_SHA + docker buildx build --platform $BUILD_PLATFORMS --push -t $IMAGE_TAG:$LATEST_MINIO_GITHUB -t $CI_REGISTRY_IMAGE:latest -t $D_IMAGE_TAG:$LATEST_MINIO_GITHUB -t $D_LATEST_TAG . + else + return 0 + fi -deploy: - image: docker:19.03 - stage: deploy - services: - - name: docker:19.03-dind - command: ["--experimental"] - before_script: - - mkdir -p ~/.docker/cli-plugins - - mv buildx ~/.docker/cli-plugins/docker-buildx - - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - script: - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker buildx create --use --name mybuilder - - docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push -t $CI_REGISTRY_IMAGE . - only: - changes: - - Dockerfile - - .gitlab-ci.yml - -# ----- Weekly Build ----- - -weekly:buildx: - image: docker:19.03-git - stage: Weekly buildx - variables: - GIT_STRATEGY: none - artifacts: - paths: - - buildx - expire_in: 3 hour - services: - - docker:19.03-dind - script: - - export DOCKER_BUILDKIT=1 - - git clone git://github.com/docker/buildx ./docker-buildx - - docker build --platform=local -o . ./docker-buildx - only: - - schedules - - master - -weekly:deploy: - image: docker:19.03 - stage: Weekly deploy - services: - - name: docker:19.03-dind - command: ["--experimental"] - before_script: - - mkdir -p ~/.docker/cli-plugins - - mv buildx ~/.docker/cli-plugins/docker-buildx - - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - script: - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker buildx create --use --name mybuilder - - docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push -t $CI_REGISTRY_IMAGE . - only: - - schedules - - master \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 417d312..3cd9b15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,19 @@ -#Pulled from: https://hub.docker.com/r/minio/minio/dockerfile - -FROM golang:1.13-alpine - -LABEL maintainer="Kelly Hair " +FROM golang:1.18-alpine as builder +LABEL maintainer="MinIO Inc " ENV GOPATH /go ENV CGO_ENABLED 0 ENV GO111MODULE on RUN \ - apk add --no-cache git && \ - git clone https://github.com/minio/minio && cd minio && \ - go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" + apk add --no-cache git jq && \ + git config --global advice.detachedHead false && \ + LATEST_MINIO_GITHUB=$(wget --quiet "https://api.github.com/repos/minio/minio/releases/latest" -O - | jq -r '.tag_name'); \ + git clone https://github.com/minio/minio && cd minio && \ + git checkout "$LATEST_MINIO_GITHUB" && go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" -FROM alpine:3.10 +FROM alpine:3.16 ENV MINIO_UPDATE off ENV MINIO_ACCESS_KEY_FILE=access_key \ @@ -24,9 +23,9 @@ ENV MINIO_ACCESS_KEY_FILE=access_key \ EXPOSE 9000 -COPY --from=0 /go/bin/minio /usr/bin/minio -COPY --from=0 /go/minio/CREDITS /third_party/ -COPY --from=0 /go/minio/dockerscripts/docker-entrypoint.sh /usr/bin/ +COPY --from=builder /go/bin/minio /usr/bin/minio +COPY --from=builder /go/minio/CREDITS /third_party/ +COPY --from=builder /go/minio/dockerscripts/docker-entrypoint.sh /usr/bin/ RUN \ apk add --no-cache ca-certificates 'curl>7.61.0' 'su-exec>=0.2' && \ @@ -36,4 +35,4 @@ ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"] VOLUME ["/data"] -CMD ["minio"] \ No newline at end of file +CMD ["minio"] diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..7190a60 --- /dev/null +++ b/renovate.json @@ -0,0 +1,3 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json" +}