From 044b2feb10d405e948c7c8f8dc856cdb9b99a3c6 Mon Sep 17 00:00:00 2001 From: Antonis Stamatiou Date: Wed, 28 Feb 2024 17:07:10 +0200 Subject: [PATCH] fix: Upgrade hadolint and fix latest docker push on Makefile --- Makefile | 32 +++++++++++++------------------- docker/Dockerfile | 6 +++--- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 03354c6..3b8aa49 100644 --- a/Makefile +++ b/Makefile @@ -51,10 +51,18 @@ DOCKER_REGISTRY_REPO ?= mattermost/${APP_NAME}-daily # Registry credentials DOCKER_USER ?= user DOCKER_PASSWORD ?= password +## Latest Docker tags +# if we are on a latest semver APP_VERSION tag, also push latest +ifneq ($(shell echo $(APP_VERSION) | egrep '^v([0-9]+\.){0,2}(\*|[0-9]+)'),) + ifeq ($(shell git tag -l --sort=v:refname | tail -n1),$(APP_VERSION)) + LATEST_DOCKER_TAG = -t $(DOCKER_REGISTRY)/${DOCKER_REGISTRY_REPO}:latest + endif +endif + ## Docker Images DOCKER_IMAGE_GO ?= "golang:${GO_VERSION}@sha256:dd9ad81920b63c7f9f18823d888d5fdcc7e7516086fd16654d07bc437f0e2427" DOCKER_IMAGE_GOLINT ?= "golangci/golangci-lint:v1.52.2@sha256:5fa6a92ab28ca3421c88d2b6cd794c9759d05a999aceca73053d014aad41b9d3" -DOCKER_IMAGE_DOCKERLINT ?= "hadolint/hadolint:v2.9.2@sha256:d355bd7df747a0f124f3b5e7b21e9dafd0cb19732a276f901f0fdee243ec1f3b" +DOCKER_IMAGE_DOCKERLINT ?= "hadolint/hadolint:v2.12.0" DOCKER_IMAGE_COSIGN ?= "bitnami/cosign:1.8.0@sha256:8c2c61c546258fffff18b47bb82a65af6142007306b737129a7bd5429d53629a" DOCKER_IMAGE_GH_CLI ?= "ghcr.io/supportpal/github-gh-cli:2.31.0@sha256:71371e36e62bd24ddd42d9e4c720a7e9954cb599475e24d1407af7190e2a5685" @@ -180,27 +188,13 @@ docker-build: ## to build the docker image -t ${APP_NAME}:${APP_VERSION_NO_V} || ${FAIL} @$(OK) Performing Docker build ${APP_NAME}:${APP_VERSION_NO_V} -.PHONY: release-docker-build -release-docker-build: docker-login - @$(INFO) Performing Release Docker build ${APP_NAME}:${APP_VERSION_NO_V} - $(AT)$(DOCKER) buildx build \ - --no-cache --pull --platform linux/amd64,linux/arm64 \ - -f ${DOCKER_FILE} . \ - -t $(DOCKER_REGISTRY)/${DOCKER_REGISTRY_REPO}:${APP_VERSION_NO_V} --push || ${FAIL} - @$(OK) Performing Release Docker build ${APP_NAME}:${APP_VERSION_NO_V} - .PHONY: docker-push docker-push: ## to push the docker image @$(INFO) Pushing to registry... - $(AT)$(DOCKER) tag ${APP_NAME}:${APP_VERSION_NO_V} $(DOCKER_REGISTRY)/${DOCKER_REGISTRY_REPO}:${APP_VERSION_NO_V} || ${FAIL} - $(AT)$(DOCKER) push $(DOCKER_REGISTRY)/${DOCKER_REGISTRY_REPO}:${APP_VERSION_NO_V} || ${FAIL} -# if we are on a latest semver APP_VERSION tag, also push latest -ifneq ($(shell echo $(APP_VERSION) | egrep '^v([0-9]+\.){0,2}(\*|[0-9]+)'),) - ifeq ($(shell git tag -l --sort=v:refname | tail -n1),$(APP_VERSION)) - $(AT)$(DOCKER) tag ${APP_NAME}:${APP_VERSION_NO_V} $(DOCKER_REGISTRY)/${DOCKER_REGISTRY_REPO}:latest || ${FAIL} - $(AT)$(DOCKER) push $(DOCKER_REGISTRY)/${DOCKER_REGISTRY_REPO}:latest || ${FAIL} - endif -endif + $(AT)$(DOCKER) buildx build \ + --no-cache --pull --platform linux/amd64,linux/arm64 \ + -f ${DOCKER_FILE} . \ + -t $(DOCKER_REGISTRY)/${DOCKER_REGISTRY_REPO}:${APP_VERSION_NO_V} $(LATEST_DOCKER_TAG) --push || ${FAIL} @$(OK) Pushing to registry $(DOCKER_REGISTRY)/${DOCKER_REGISTRY_REPO}:${APP_VERSION_NO_V} .PHONY: docker-sign diff --git a/docker/Dockerfile b/docker/Dockerfile index 62d749e..d01e3f4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,9 +5,9 @@ ARG TARGETARCH SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Copying tarball -RUN mkdir /mattermost-push-proxy -COPY dist/mattermost-push-proxy-linux-${TARGETARCH}.tar.gz dist/mattermost-push-proxy-linux.tar.gz -RUN tar -xf dist/mattermost-push-proxy-linux.tar.gz --strip-components=1 -C /mattermost-push-proxy +WORKDIR /mattermost-push-proxy +COPY dist/mattermost-push-proxy-linux-${TARGETARCH}.tar.gz /mattermost-push-proxy-linux.tar.gz +RUN tar -xf /mattermost-push-proxy-linux.tar.gz --strip-components=1 -C /mattermost-push-proxy FROM --platform=${TARGETPLATFORM} ubuntu:jammy-20240212