detached 0461a54

CI/CD: Remove build_dev workflow and optimize Dockerfile

- Comment out entire build_dev.yml workflow
- Refactor Dockerfile for multi-arch support and local builds
- Optimize image size and streamline container setup
commit
0461a54ec596094b11c67be61193bd024b2276aa
author
bamen · · 2024-08-26 19:51 UTC
committer
bamen · · 2024-08-26 17:43 UTC
parent
932fd9f
signature
unsigned
3 files · +88 -47
M .github/workflows/build_dev.yml +39 -39
@@ -1,39 +1,39 @@
1-name: Build and Test Gordon
2-
3-on:
4- push:
5- branches:
6- - "dev"
7-
8-jobs:
9- build-and-test:
10- name: Build and Test
11- runs-on: ubuntu-latest
12- permissions:
13- contents: read
14- packages: write
15- env:
16- KO_DOCKER_REPO: ghcr.io/${{ github.repository }}
17-
18- steps:
19- - uses: actions/setup-go@v4
20- with:
21- go-version: "1.23"
22-
23- - uses: actions/checkout@v3
24-
25- # - name: Run tests
26- # run: go test ./...
27-
28- - name: Log in to GitHub Container Registry
29- uses: docker/login-action@v2
30- with:
31- registry: ghcr.io
32- username: ${{ github.actor }}
33- password: ${{ secrets.GITHUB_TOKEN }}
34-
35- - uses: ko-build/setup-ko@v0.6
36-
37- - name: Build and push with ko
38- run: |
39- ko build --platform=linux/amd64,linux/arm64 --bare --tags=dev -B ./cmd/cli --base-import-paths=false --image-refs=gordon-dev
1+# name: Build and Test Gordon
2+
3+# on:
4+# push:
5+# branches:
6+# - "dev"
7+
8+# jobs:
9+# build-and-test:
10+# name: Build and Test
11+# runs-on: ubuntu-latest
12+# permissions:
13+# contents: read
14+# packages: write
15+# env:
16+# KO_DOCKER_REPO: ghcr.io/${{ github.repository }}
17+
18+# steps:
19+# - uses: actions/setup-go@v4
20+# with:
21+# go-version: "1.23"
22+
23+# - uses: actions/checkout@v3
24+
25+# # - name: Run tests
26+# # run: go test ./...
27+
28+# - name: Log in to GitHub Container Registry
29+# uses: docker/login-action@v2
30+# with:
31+# registry: ghcr.io
32+# username: ${{ github.actor }}
33+# password: ${{ secrets.GITHUB_TOKEN }}
34+
35+# - uses: ko-build/setup-ko@v0.6
36+
37+# - name: Build and push with ko
38+# run: |
39+# ko build --platform=linux/amd64,linux/arm64 --bare --tags=dev -B ./cmd/cli --base-import-paths=false --image-refs=gordon-dev
@@ -1,39 +1,39 @@
1-name: Build and Test Gordon1+# name: Build and Test Gordon
2-2+
3-on:3+# on:
4- push:4+# push:
5- branches:5+# branches:
6- - "dev"6+# - "dev"
7-7+
8-jobs:8+# jobs:
9- build-and-test:9+# build-and-test:
10- name: Build and Test10+# name: Build and Test
11- runs-on: ubuntu-latest11+# runs-on: ubuntu-latest
12- permissions:12+# permissions:
13- contents: read13+# contents: read
14- packages: write14+# packages: write
15- env:15+# env:
16- KO_DOCKER_REPO: ghcr.io/${{ github.repository }}16+# KO_DOCKER_REPO: ghcr.io/${{ github.repository }}
17-17+
18- steps:18+# steps:
19- - uses: actions/setup-go@v419+# - uses: actions/setup-go@v4
20- with:20+# with:
21- go-version: "1.23"21+# go-version: "1.23"
22-22+
23- - uses: actions/checkout@v323+# - uses: actions/checkout@v3
24-24+
25- # - name: Run tests25+# # - name: Run tests
26- # run: go test ./...26+# # run: go test ./...
27-27+
28- - name: Log in to GitHub Container Registry28+# - name: Log in to GitHub Container Registry
29- uses: docker/login-action@v229+# uses: docker/login-action@v2
30- with:30+# with:
31- registry: ghcr.io31+# registry: ghcr.io
32- username: ${{ github.actor }}32+# username: ${{ github.actor }}
33- password: ${{ secrets.GITHUB_TOKEN }}33+# password: ${{ secrets.GITHUB_TOKEN }}
34-34+
35- - uses: ko-build/setup-ko@v0.635+# - uses: ko-build/setup-ko@v0.6
36-36+
37- - name: Build and push with ko37+# - name: Build and push with ko
38- run: |38+# run: |
39- ko build --platform=linux/amd64,linux/arm64 --bare --tags=dev -B ./cmd/cli --base-import-paths=false --image-refs=gordon-dev39+# ko build --platform=linux/amd64,linux/arm64 --bare --tags=dev -B ./cmd/cli --base-import-paths=false --image-refs=gordon-dev
M Dockerfile +11 -8
@@ -1,12 +1,15 @@
1-# Use a minimal base image
2-FROM alpine
3-# Install ca-certificates bundle
4-RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
5-# Copy the binary
6-COPY gordon /gordon
7-# Copy other necessary files
8-COPY .iscontainer /
1+# Start from scratch
2+FROM alpine:latest
3+
4+ARG ARCH
5+
6+# Copy the pre-built binary for the specific architecture
7+COPY dist/gordon-linux-${ARCH} /gordon
8+# Create the .iscontainer file
9+RUN touch /.iscontainer
10+
911 # Set the entrypoint
1012 ENTRYPOINT ["/gordon"]
13+
1114 # Default command
1215 CMD ["serve"]
@@ -1,12 +1,15 @@
1-# Use a minimal base image1+# Start from scratch
2-FROM alpine2+FROM alpine:latest
3-# Install ca-certificates bundle3+
4-RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*4+ARG ARCH
5-# Copy the binary5+
6-COPY gordon /gordon6+# Copy the pre-built binary for the specific architecture
7-# Copy other necessary files7+COPY dist/gordon-linux-${ARCH} /gordon
8-COPY .iscontainer /8+# Create the .iscontainer file
9+RUN touch /.iscontainer
10+
9 # Set the entrypoint11 # Set the entrypoint
10 ENTRYPOINT ["/gordon"]12 ENTRYPOINT ["/gordon"]
13+
11 # Default command14 # Default command
12 CMD ["serve"]15 CMD ["serve"]
A buildpush-dev.sh +38 -0
@@ -0,0 +1,38 @@
1+#!/bin/bash
2+
3+set -e
4+
5+REPO="ghcr.io/bnema/gordon"
6+TAG="dev"
7+DIST_DIR="./dist"
8+
9+# Ensure dist directory exists
10+mkdir -p $DIST_DIR
11+
12+# Build Go binaries for multiple platforms with CGO_ENABLED=0
13+echo "Building Go binaries..."
14+CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $DIST_DIR/gordon-linux-amd64 ./cmd/cli
15+CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $DIST_DIR/gordon-linux-arm64 ./cmd/cli
16+
17+# Build Docker images for each architecture
18+echo "Building Docker images..."
19+docker build -t $REPO:${TAG}-amd64 --build-arg ARCH=amd64 -f Dockerfile .
20+docker build -t $REPO:${TAG}-arm64v8 --build-arg ARCH=arm64 -f Dockerfile .
21+
22+# Push images
23+echo "Pushing Docker images..."
24+docker push $REPO:${TAG}-amd64
25+docker push $REPO:${TAG}-arm64v8
26+
27+# Create and push multi-arch manifest
28+echo "Creating and pushing multi-arch manifest..."
29+docker manifest create $REPO:$TAG \
30+ $REPO:${TAG}-amd64 \
31+ $REPO:${TAG}-arm64v8 \
32+ --amend
33+
34+# Annotate the arm64 image with variant information
35+docker manifest annotate $REPO:$TAG \
36+ $REPO:${TAG}-arm64v8 --arch arm64 --variant v8
37+
38+docker manifest push $REPO:$TAG
@@ -0,0 +1,38 @@
1+#!/bin/bash
2+
3+set -e
4+
5+REPO="ghcr.io/bnema/gordon"
6+TAG="dev"
7+DIST_DIR="./dist"
8+
9+# Ensure dist directory exists
10+mkdir -p $DIST_DIR
11+
12+# Build Go binaries for multiple platforms with CGO_ENABLED=0
13+echo "Building Go binaries..."
14+CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $DIST_DIR/gordon-linux-amd64 ./cmd/cli
15+CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $DIST_DIR/gordon-linux-arm64 ./cmd/cli
16+
17+# Build Docker images for each architecture
18+echo "Building Docker images..."
19+docker build -t $REPO:${TAG}-amd64 --build-arg ARCH=amd64 -f Dockerfile .
20+docker build -t $REPO:${TAG}-arm64v8 --build-arg ARCH=arm64 -f Dockerfile .
21+
22+# Push images
23+echo "Pushing Docker images..."
24+docker push $REPO:${TAG}-amd64
25+docker push $REPO:${TAG}-arm64v8
26+
27+# Create and push multi-arch manifest
28+echo "Creating and pushing multi-arch manifest..."
29+docker manifest create $REPO:$TAG \
30+ $REPO:${TAG}-amd64 \
31+ $REPO:${TAG}-arm64v8 \
32+ --amend
33+
34+# Annotate the arm64 image with variant information
35+docker manifest annotate $REPO:$TAG \
36+ $REPO:${TAG}-arm64v8 --arch arm64 --variant v8
37+
38+docker manifest push $REPO:$TAG

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close