From bc8c0e32453f116c7dc9c4ce6f6f4a5eed72a518 Mon Sep 17 00:00:00 2001 From: obvionaoe Date: Thu, 2 Mar 2023 01:55:45 +0000 Subject: [PATCH] fixed Dockerfile --- .github/workflows/build.yml | 4 ++-- Dockerfile | 36 +++--------------------------------- entrypoint.sh | 2 +- 3 files changed, 6 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9a7d54..2e73e08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,11 +15,11 @@ jobs: - name: Install skopeo run: sudo apt install skopeo - - name: Get latest tag if more recent than latest DockerHub tag + - name: Get all tags that are not in DockerHub yet id: get_tag run: | get_latest() { - local git=$(curl --silent "https://api.github.com/repos/bojand/ghz/git/refs/tags" | jq -r '.[].ref' | sed '1d' | sed 's/^refs\/tags\///g' | paste -d, -s) + local git=$(curl --silent "https://api.github.com/repos/bojand/ghz/git/refs/tags" | jq -r '.[].ref' | sed '50d' | sed 's/^refs\/tags\///g' | paste -d, -s) local docker=$(skopeo inspect docker://obvionaoe/ghz | jq -r '.RepoTags[]' | sed '1d' | sort -V | paste -d, -s) local result="\"" diff --git a/Dockerfile b/Dockerfile index b04327a..a92a500 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,48 +1,18 @@ -################################## -# STEP 1 build executable binary # -################################## - FROM golang:alpine AS builder -# Install git. -# Git is required for fetching the dependencies. -RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates -WORKDIR $GOPATH/src/ - -# Set version var ARG APP_VERSION -# Clone the branch for the given version -RUN git clone --depth 1 --branch ${APP_VERSION} https://github.com/bojand/ghz -WORKDIR $GOPATH/src/ghz/cmd/ghz - -# Fetch dependencies using go get. -RUN go get -d -v - -# Build the binary. -RUN CGO_ENABLED=0 go build -o /go/bin/ghz - -############################## -# STEP 2 build a small image # -############################## +RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates +RUN go install github.com/bojand/ghz/cmd/ghz@${APP_VERSION} FROM alpine RUN apk update && apk add --no-cache httpie ca-certificates && update-ca-certificates -# Import from the builder image. COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -# Copy our static executable from the builder image. COPY --from=builder /go/bin/ghz /go/bin/ghz - -# Create directories -RUN mkdir -p /ghz/protos - -# Copy our entrypoint script COPY entrypoint.sh . -# Change its owner +RUN mkdir -p /ghz/protos RUN chmod +x entrypoint.sh -# Set it as entrypoint ENTRYPOINT ["./entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 436dc8a..02b70b8 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/sh -exec /go/bin/ghz "$@" +/go/bin/ghz "$@" # Print helpFunction in case exit code is not 0 if [ $? != 0 ]; then