Skip to content

Commit bdc674f

Browse files
committed
try readding upx and remove parallel builds
1 parent a1930fb commit bdc674f

File tree

3 files changed

+33
-147
lines changed

3 files changed

+33
-147
lines changed

.github/workflows/build_images.yaml

+8-122
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88

99
jobs:
1010

11-
build-amd64:
12-
name: Build amd64 Docker Image
11+
build-images:
12+
name: Build Docker Images
1313
runs-on: ubuntu-latest
1414
steps:
1515
# Check out code
@@ -23,123 +23,9 @@ jobs:
2323
echo ::set-output name=tag::$([[ "${GITHUB_REF##*/}" == "main" ]] && echo latest || echo ${GITHUB_REF##*/})
2424
id: version
2525

26-
# Set up a buildx runner
27-
- name: Set up Docker Buildx
28-
uses: docker/setup-buildx-action@v1
29-
30-
# Set up an Docker layer cache
31-
- name: Cache Docker layers
32-
uses: actions/cache@v2
33-
with:
34-
path: /tmp/.buildx-cache
35-
key: ${{ runner.os }}-amd64-buildx-${{ github.sha }}
36-
restore-keys: |
37-
${{ runner.os }}-amd64-buildx-
38-
39-
# Login to the container registry
40-
- name: Login to Container Registry
41-
run: echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
42-
if: ${{ github.event_name != 'pull_request' }}
43-
44-
- name: Patch buildx multiarch image
45-
run: |
46-
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
47-
docker buildx create --name multiarch --driver docker-container --use
48-
docker buildx inspect --bootstrap
49-
50-
# Build and push the image
51-
- name: Build and Push Controller Image
52-
uses: docker/build-push-action@v2
53-
with:
54-
platforms: linux/amd64
55-
push: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
56-
tags: ghcr.io/pelotech/jsonnet-controller:${{ steps.version.outputs.tag }}
57-
cache-from: type=local,src=/tmp/.buildx-cache
58-
cache-to: type=local,dest=/tmp/.buildx-cache-new
59-
60-
# This ugly bit is necessary if you don't want your cache to grow forever
61-
# till it hits GitHub's limit of 5GB.
62-
# Temp fix
63-
# https://github.com/docker/build-push-action/issues/252
64-
# https://github.com/moby/buildkit/issues/1896
65-
- name: Move cache
66-
run: |
67-
rm -rf /tmp/.buildx-cache
68-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
69-
70-
build-arm64:
71-
name: Build arm64 Docker Image
72-
runs-on: ubuntu-latest
73-
steps:
74-
# Check out code
75-
- name: Checkout
76-
uses: actions/checkout@v2
77-
78-
# Determine tag we will use for images
79-
- name: Get image version
80-
shell: bash
81-
run: |
82-
echo ::set-output name=tag::$([[ "${GITHUB_REF##*/}" == "main" ]] && echo latest || echo ${GITHUB_REF##*/})
83-
id: version
84-
85-
# Set up a buildx runner
86-
- name: Set up Docker Buildx
87-
uses: docker/setup-buildx-action@v1
88-
89-
# Set up an Docker layer cache
90-
- name: Cache Docker layers
91-
uses: actions/cache@v2
92-
with:
93-
path: /tmp/.buildx-cache
94-
key: ${{ runner.os }}-arm64-buildx-${{ github.sha }}
95-
restore-keys: |
96-
${{ runner.os }}-arm64-buildx-
97-
98-
# Login to the container registry
99-
- name: Login to Container Registry
100-
run: echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
101-
if: ${{ github.event_name != 'pull_request' }}
102-
103-
- name: Patch buildx multiarch image
104-
run: |
105-
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
106-
docker buildx create --name multiarch --driver docker-container --use
107-
docker buildx inspect --bootstrap
108-
109-
# Build and push the image
110-
- name: Build and Push Controller Image
111-
uses: docker/build-push-action@v2
112-
with:
113-
platforms: linux/arm64
114-
push: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
115-
tags: ghcr.io/pelotech/jsonnet-controller:${{ steps.version.outputs.tag }}
116-
cache-from: type=local,src=/tmp/.buildx-cache
117-
cache-to: type=local,dest=/tmp/.buildx-cache-new
118-
119-
# This ugly bit is necessary if you don't want your cache to grow forever
120-
# till it hits GitHub's limit of 5GB.
121-
# Temp fix
122-
# https://github.com/docker/build-push-action/issues/252
123-
# https://github.com/moby/buildkit/issues/1896
124-
- name: Move cache
125-
run: |
126-
rm -rf /tmp/.buildx-cache
127-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
128-
129-
build-armv7:
130-
name: Build armv7 Docker Image
131-
runs-on: ubuntu-latest
132-
steps:
133-
# Check out code
134-
- name: Checkout
135-
uses: actions/checkout@v2
136-
137-
# Determine tag we will use for images
138-
- name: Get image version
139-
shell: bash
140-
run: |
141-
echo ::set-output name=tag::$([[ "${GITHUB_REF##*/}" == "main" ]] && echo latest || echo ${GITHUB_REF##*/})
142-
id: version
26+
# Setup QEMU
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v1
14329

14430
# Set up a buildx runner
14531
- name: Set up Docker Buildx
@@ -150,9 +36,9 @@ jobs:
15036
uses: actions/cache@v2
15137
with:
15238
path: /tmp/.buildx-cache
153-
key: ${{ runner.os }}-armv7-buildx-${{ github.sha }}
39+
key: ${{ runner.os }}-buildx-${{ github.sha }}
15440
restore-keys: |
155-
${{ runner.os }}-armv7-buildx-
41+
${{ runner.os }}-buildx-
15642
15743
# Login to the container registry
15844
- name: Login to Container Registry
@@ -169,7 +55,7 @@ jobs:
16955
- name: Build and Push Controller Image
17056
uses: docker/build-push-action@v2
17157
with:
172-
platforms: linux/arm/v7
58+
platforms: linux/amd64,linux/arm64,linux/arm/v7
17359
push: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
17460
tags: ghcr.io/pelotech/jsonnet-controller:${{ steps.version.outputs.tag }}
17561
cache-from: type=local,src=/tmp/.buildx-cache

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM golang:1.16 as builder
22

3-
# RUN apt-get update && apt-get install -y upx
3+
RUN apt-get update && apt-get install -y upx
44

55
WORKDIR /workspace
66

@@ -18,7 +18,7 @@ COPY controllers/ controllers/
1818
COPY pkg/ pkg/
1919

2020
# Build
21-
RUN CGO_ENABLED=0 GOOS=linux go build -tags netgo -ldflags="-s -w" -a -o manager main.go
21+
RUN CGO_ENABLED=0 GOOS=linux go build -tags netgo -ldflags="-s -w" -a -o manager main.go && upx -9 manager
2222

2323
# Use distroless as minimal base image to package the manager binary
2424
# Refer to https://github.com/GoogleContainerTools/distroless for more details

config/bundle/manifest.yaml

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
11
---
2-
apiVersion: v1
3-
kind: Service
4-
metadata:
5-
annotations: {}
6-
labels:
7-
app: jsonnet-controller
8-
control_plane: manager
9-
name: jsonnet-controller
10-
namespace: flux-system
11-
spec:
12-
ports:
13-
- name: http
14-
port: 9443
15-
targetPort: 9443
16-
- name: metrics
17-
port: 8080
18-
targetPort: 8080
19-
selector:
20-
app: jsonnet-controller
21-
control_plane: manager
22-
type: ClusterIP
23-
---
242
apiVersion: apiextensions.k8s.io/v1
253
kind: CustomResourceDefinition
264
metadata:
@@ -427,7 +405,7 @@ spec:
427405
valueFrom:
428406
fieldRef:
429407
fieldPath: metadata.namespace
430-
image: ghcr.io/pelotech/jsonnet-controller:latest
408+
image: ghcr.io/pelotech/jsonnet-controller:v0.0.4
431409
imagePullPolicy: IfNotPresent
432410
livenessProbe:
433411
httpGet:
@@ -620,3 +598,25 @@ subjects:
620598
- kind: ServiceAccount
621599
name: jsonnet-controller-sa
622600
namespace: flux-system
601+
---
602+
apiVersion: v1
603+
kind: Service
604+
metadata:
605+
annotations: {}
606+
labels:
607+
app: jsonnet-controller
608+
control_plane: manager
609+
name: jsonnet-controller
610+
namespace: flux-system
611+
spec:
612+
ports:
613+
- name: http
614+
port: 9443
615+
targetPort: 9443
616+
- name: metrics
617+
port: 8080
618+
targetPort: 8080
619+
selector:
620+
app: jsonnet-controller
621+
control_plane: manager
622+
type: ClusterIP

0 commit comments

Comments
 (0)