-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make image using Dockerfile // add gke auth plugin dependency
- Loading branch information
Showing
4 changed files
with
58 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ jobs: | |
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.19 | ||
go-version: 1.20 | ||
- run: make test | ||
|
||
publish: | ||
|
@@ -24,27 +24,37 @@ jobs: | |
runs-on: ubuntu-latest | ||
if: github.event_name != 'pull_request' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/setup-buildx-action@v3 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- uses: Surgo/docker-smart-tag-action@v1 | ||
id: smarttag | ||
with: | ||
docker_image: "" | ||
docker_image: "tsuru/acl-api" | ||
default_branch: main | ||
tag_with_sha: "true" | ||
- uses: actions/setup-go@v2 | ||
- name: Handle smart-tag to proper tag var | ||
uses: actions/github-script@v6 | ||
id: handle_tag | ||
with: | ||
go-version: 1.19 | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: imjasonh/[email protected] | ||
env: | ||
KO_DOCKER_REPO: tsuru | ||
- env: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
KO_DEFAULTBASEIMAGE: alpine:3.17.1 | ||
TO_BUILD_TAG: ${{ steps.smarttag.outputs.tag }} | ||
run: | | ||
export TAGS=$(echo -n "${TO_BUILD_TAG}" | sed 's/://g') | ||
echo "Lets build tags: ${TAGS}" | ||
echo "${DOCKERHUB_PASSWORD}" | ko login docker.io --username ${DOCKERHUB_USERNAME} --password-stdin | ||
ko build -B --platform linux/arm64,linux/amd64 -t ${TAGS} | ||
script: | | ||
var tag_re = /:/g | ||
var orig_tags = `${{steps.smarttag.outputs.tag}}` | ||
return orig_tags.replace(tag_re,"") | ||
- uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.handle_tag.outputs.result }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
platforms: linux/amd64,linux/arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
*.dll | ||
*.so | ||
*.dylib | ||
*.test | ||
*.test | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM golang:1.20-alpine3.18 AS builder | ||
COPY . /go/src/github.com/tsuru/acl-api | ||
WORKDIR /go/src/github.com/tsuru/acl-api | ||
RUN set -x \ | ||
&& apk add --update gcc git make musl-dev \ | ||
&& make build | ||
|
||
FROM alpine:3.18 | ||
COPY --from=builder /go/src/github.com/tsuru/acl-api/bin/acl-api /bin/acl-api | ||
ARG gke_auth_plugin_version=0.1.1 | ||
ARG TARGETARCH | ||
RUN set -x \ | ||
&& apk add --update --no-cache curl ca-certificates \ | ||
&& curl -fsSL "https://github.com/traviswt/gke-auth-plugin/releases/download/${gke_auth_plugin_version}/gke-auth-plugin_Linux_$( [[ ${TARGETARCH} == 'amd64' ]] && echo 'x86_64' || echo ${TARGETARCH} ).tar.gz" \ | ||
| tar -C /usr/local/bin -xzvf- gke-auth-plugin \ | ||
&& gke-auth-plugin version | ||
CMD ["/bin/acl-api"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters