File tree 3 files changed +54
-0
lines changed
3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Build and Push Container Image
2
+ on : [push]
3
+ env :
4
+ IMAGE_NAME : ghcr.io/4armed/metacreds
5
+
6
+ jobs :
7
+ build-and-push :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - name : Checkout code
11
+ uses : actions/checkout@v2
12
+ - name : Login to GitHub Container Registry
13
+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
14
+ - name : Get version
15
+ id : vars
16
+ run : echo ::set-output name=tag::$(echo ${GITHUB_SHA} | cut -c1-7)
17
+ - name : Build the tagged Docker image
18
+ run : docker build . -f build/Dockerfile --tag ${{ env.IMAGE_NAME }}:${{steps.vars.outputs.tag}} --build-arg EXECUTABLE=metacreds
19
+ - name : Push the tagged Docker image
20
+ run : docker push ${{ env.IMAGE_NAME }}:${{steps.vars.outputs.tag}}
21
+ - name : Tag image as latest
22
+ run : docker tag ${{ env.IMAGE_NAME }}:${{steps.vars.outputs.tag}} ${{ env.IMAGE_NAME }}:latest
23
+ - name : Push latest
24
+ run : docker push ${{ env.IMAGE_NAME }}:latest
Original file line number Diff line number Diff line change
1
+ EXECUTABLE := $(EXECUTABLE )
2
+
3
+ clean :
4
+ @rm -f ${EXECUTABLE}
5
+
6
+ install : clean
7
+ go install -a -tags netgo -ldflags " -w -extldflags '-static'"
8
+
9
+ docker :
10
+ docker build -f build/Dockerfile . -t ${EXECUTABLE} --build-arg EXECUTABLE=$(EXECUTABLE )
Original file line number Diff line number Diff line change
1
+ FROM golang:1.17-alpine AS build
2
+
3
+ ENV CGO_ENABLED=0
4
+
5
+ RUN apk add --no-cache \
6
+ git \
7
+ curl \
8
+ make
9
+
10
+ WORKDIR /src
11
+ COPY . .
12
+ RUN make install
13
+
14
+ FROM gcr.io/distroless/base
15
+
16
+ ARG EXECUTABLE
17
+ ENV EXECUTABLE=$EXECUTABLE
18
+
19
+ COPY --from=build /go/bin/${EXECUTABLE} /metacreds
20
+ ENTRYPOINT ["/metacreds" ]
You can’t perform that action at this time.
0 commit comments