Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 6a0c298

Browse files
author
Sameer Naik
committed
gh-actions: build and publish triggermesh-core controller image to gcr.io
1 parent 19f51da commit 6a0c298

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Top level files and directories
2+
/.git/
3+
/.github/
4+
/test/
5+
/hack/
6+
!/hack/inc.Codegen.mk
7+
/.dockerignore
8+
9+
# Patterns
10+
**/config/
11+
**/*.md
12+
**/*_test.go
13+
**/.gitignore
14+
**/Dockerfile
15+
16+
# Binaries

.github/workflows/container.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Container images
2+
3+
on:
4+
workflow_dispatch:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- 'v*'
12+
pull_request:
13+
14+
jobs:
15+
container_image:
16+
name: Build container image
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up Docker Buildx
26+
id: buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
- name: Login to GCR
30+
uses: docker/login-action@v2
31+
with:
32+
registry: gcr.io
33+
username: _json_key
34+
password: ${{ secrets.GCLOUD_SERVICEACCOUNT_KEY }}
35+
36+
- name: Docker metadata
37+
id: meta
38+
uses: docker/metadata-action@v4
39+
with:
40+
images: gcr.io/triggermesh/triggermesh-core
41+
tags: |
42+
type=semver,pattern={{raw}}
43+
latest
44+
45+
- name: Build and push image
46+
uses: docker/build-push-action@v3
47+
with:
48+
context: .
49+
file: cmd/core-controller/Dockerfile
50+
push: ${{ github.event_name != 'pull_request' }}
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*.rej
2020

2121
# Build artifacts
22-
/_output/
22+
/releases/
2323

2424
# Test artifacts
2525
*.test

cmd/core-controller/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2022 TriggerMesh Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM golang:1.19 AS builder
16+
17+
ENV CGO_ENABLED 0
18+
ENV GOOS linux
19+
ENV GOARCH amd64
20+
21+
WORKDIR /go/src/project
22+
23+
COPY go.mod go.sum ./
24+
RUN go mod download
25+
26+
COPY . .
27+
RUN go build -a -o triggermesh-core ./cmd/core-controller
28+
29+
FROM gcr.io/distroless/static:nonroot
30+
31+
COPY --from=builder /go/src/project/triggermesh-core /
32+
COPY LICENSE EULA.pdf /licenses/
33+
34+
USER 65532:65532
35+
36+
ENTRYPOINT ["/triggermesh-core"]

0 commit comments

Comments
 (0)