Skip to content

Commit

Permalink
fixed Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
obvionaoe committed Mar 2, 2023
1 parent 85e900f commit bc8c0e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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="\""
Expand Down
36 changes: 3 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit bc8c0e3

Please sign in to comment.