Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added arm64 build #5420

Merged
merged 8 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 8 additions & 38 deletions .github/workflows/publish_image_chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ env:
GHCR: ghcr.io
GCR: gcr.io
HELM_VERSION: 3.8.2
GO_VERSION: 1.22.4
NODE_VERSION: 16.13.0

jobs:
artifacts:
Expand Down Expand Up @@ -59,40 +57,12 @@ jobs:
container_registry: gcr.io/pipecd

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Determine version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ASK] Is this line still needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ponkio-o
Sorry for the wrong selection.
I'm asking about only this line.

  - name: Determine version

Copy link
Contributor Author

@ponkio-o ponkio-o Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the below line is needed.

run: echo "PIPECD_VERSION=$(git describe --tags --always --abbrev=7)" >> $GITHUB_ENV

Fixed in the following commit.
1fb5523

run: echo "PIPECD_VERSION=$(git describe --tags --always --abbrev=7)" >> $GITHUB_ENV

# Building go modules.
- name: Build go modules
run: make build/go

# Building web.
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Update web dependencies
run: make update/web-deps
- name: Build web static
run: make build/web

# Setup QEMU and Buildx.
# Setup QEMU and Buildx.
- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 #v2.0.0
- name: Set up Docker Buildx
Expand All @@ -115,14 +85,14 @@ jobs:

# Building and pushing container images.
- name: Build and push ${{ matrix.image }} image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5.0.0
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
with:
push: true
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
tags: ${{ matrix.container_registry }}/${{ matrix.image }}:${{ env.PIPECD_VERSION }}

# Building and pushing Helm charts.
- name: Install helm
uses: Azure/setup-helm@v1
Expand Down Expand Up @@ -161,7 +131,7 @@ jobs:
uses: Azure/setup-helm@v1
with:
version: ${{ env.HELM_VERSION }}
- uses: actions/checkout@v3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
ref: master
Expand All @@ -175,9 +145,9 @@ jobs:
- name: Publish quickstart manifests
uses: peter-evans/create-pull-request@v6
with:
title: "[bot] Publish quickstart manifests"
commit-message: "[bot] Publish quickstart manifests"
branch: "create-pull-request/publish-quickstart-manifests"
title: '[bot] Publish quickstart manifests'
commit-message: '[bot] Publish quickstart manifests'
branch: 'create-pull-request/publish-quickstart-manifests'
body: |
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action.
The workflow is defined [here](https://github.com/pipe-cd/pipecd/blob/master/.github/workflows/publish_image_chart.yaml).
Expand Down
13 changes: 12 additions & 1 deletion cmd/helloworld/Dockerfile
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, binaries built for linux/amd64 on CI are added to the image, but I have changed to build them inside the Dockerfile. This will automatically configure GOARCH and other settings.

As noted in the Issue, the linux/arm64 docker image exists, but the binary that exits in the image is linux/amd64, which is the cause of the current error.

Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
FROM golang:1.23.3 AS builder

WORKDIR /app

COPY go.* ./
RUN go mod download

COPY . ./

RUN make build/go MOD=helloworld

FROM alpine:3.21.0

ADD .artifacts/helloworld /usr/local/bin/helloworld
COPY --from=builder /app/.artifacts/helloworld /usr/local/bin/helloworld

ENTRYPOINT ["helloworld"]
17 changes: 14 additions & 3 deletions cmd/launcher/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base/301720292?tag=v0.49.3
FROM ghcr.io/pipe-cd/piped-base@sha256:e5ce81bfd81b6d8d24b2caf9ec482c3f6d11fff7ab96f6cc6fc854e82376fb3d
FROM golang:1.23.3 AS builder

ADD .artifacts/launcher /usr/local/bin/launcher
WORKDIR /app

COPY go.* ./
RUN go mod download

COPY . ./

RUN make build/go MOD=launcher

# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base/321463679?tag=v0.50.0-26-ga8527d2
FROM ghcr.io/pipe-cd/piped-base@sha256:9960b45a5aa822ae45ca2966056d8d2e98795b51681df25afd1fecf96360981c

COPY --from=builder /app/.artifacts/launcher /usr/local/bin/launcher

ENTRYPOINT ["launcher"]
17 changes: 14 additions & 3 deletions cmd/launcher/Dockerfile-okd
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base-okd/237191933?tag=v0.47.3-rc0-21-ge20cd0b
FROM ghcr.io/pipe-cd/piped-base-okd@sha256:afb1bfee70d445986d04c2066d2887da7b1e2e454cecabec5bf37e3201cd7e7e
FROM golang:1.23.3 AS builder

ADD .artifacts/launcher /usr/local/bin/launcher
WORKDIR /app

COPY go.* ./
RUN go mod download

COPY . ./

RUN make build/go MOD=launcher

# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base-okd/321464518?tag=v0.50.0-26-ga8527d2
FROM ghcr.io/pipe-cd/piped-base-okd@sha256:da9bd5a1dae3aa5c2df4baba81ff836ba4a55159d85984605549ef2d1f136895

COPY --from=builder /app/.artifacts/launcher /usr/local/bin/launcher

ENTRYPOINT ["launcher"]
27 changes: 25 additions & 2 deletions cmd/pipecd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# web builder
FROM node:20.18.1-alpine3.21 AS web

WORKDIR /app

COPY . .

RUN apk add --no-cache make
RUN make update/web-deps
RUN make build/web

# pipecd builder
FROM golang:1.23.3 AS builder

WORKDIR /app

COPY go.* ./
RUN go mod download

COPY . ./

RUN make build/go MOD=pipecd

Copy link
Contributor

@Warashi Warashi Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, we use git in our Makefile in many places, so please install git in web and go builder?

build/go: BUILD_VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7)

"build": "PIPECD_VERSION=`git describe --tags --always --dirty --abbrev=7` webpack build --mode production --env htmlTemplate=./base.html --config ./webpack.config.js",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Warashi Thank you for your review. I installed git command to builder container on below commit.
beb90e7

And golang:1.23.3 has been installed git already.

$ docker run --rm -it golang:1.23.3 git --help
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone     Clone a repository into a new directory
   init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   restore   Restore working tree files
   rm        Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect    Use binary search to find the commit that introduced a bug
   diff      Show changes between commits, commit and working tree, etc
   grep      Print lines matching a pattern
   log       Show commit logs
   show      Show various types of objects
   status    Show the working tree status

grow, mark and tweak your common history
   branch    List, create, or delete branches
   commit    Record changes to the repository
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   reset     Reset current HEAD to the specified state
   switch    Switch branches
   tag       Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch     Download objects and refs from another repository
   pull      Fetch from and integrate with another repository or a local branch
   push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

FROM alpine:3.21.0

ARG GOOGLE_CLOUD_SDK_VERSION=477.0.0
Expand All @@ -15,7 +38,7 @@ ENV PATH="/google-cloud-sdk/bin:${PATH}"

RUN mkdir -p web/static

ADD .artifacts/pipecd /usr/local/bin/pipecd
ADD .artifacts/web-static web/static
COPY --from=builder /app/.artifacts/pipecd /usr/local/bin/pipecd
COPY --from=web /app/.artifacts/web-static web/static

ENTRYPOINT ["pipecd"]
13 changes: 12 additions & 1 deletion cmd/pipectl/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
FROM golang:1.23.3 AS builder

WORKDIR /app

COPY go.* ./
RUN go mod download

COPY . ./

RUN make build/go MOD=pipectl

FROM alpine:3.21.0

RUN apk add --no-cache git

ADD .artifacts/pipectl /usr/local/bin/pipectl
COPY --from=builder /app/.artifacts/pipectl /usr/local/bin/pipectl

ENTRYPOINT ["pipectl"]
17 changes: 14 additions & 3 deletions cmd/piped/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base/301720292?tag=v0.49.3
FROM ghcr.io/pipe-cd/piped-base@sha256:e5ce81bfd81b6d8d24b2caf9ec482c3f6d11fff7ab96f6cc6fc854e82376fb3d
FROM golang:1.23.3 AS builder

ADD .artifacts/piped /usr/local/bin/piped
WORKDIR /app

COPY go.* ./
RUN go mod download

COPY . ./

RUN make build/go MOD=piped

# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base/321463679?tag=v0.50.0-26-ga8527d2
FROM ghcr.io/pipe-cd/piped-base@sha256:9960b45a5aa822ae45ca2966056d8d2e98795b51681df25afd1fecf96360981c

COPY --from=builder /app/.artifacts/piped /usr/local/bin/piped

ENTRYPOINT ["piped"]
17 changes: 14 additions & 3 deletions cmd/piped/Dockerfile-okd
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base-okd/237191933?tag=v0.47.3-rc0-21-ge20cd0b
FROM ghcr.io/pipe-cd/piped-base-okd@sha256:afb1bfee70d445986d04c2066d2887da7b1e2e454cecabec5bf37e3201cd7e7e
FROM golang:1.23.3 AS builder

ADD .artifacts/piped /usr/local/bin/piped
WORKDIR /app

COPY go.* ./
RUN go mod download

COPY . ./

RUN make build/go MOD=piped

# https://github.com/pipe-cd/pipecd/pkgs/container/piped-base-okd/321464518?tag=v0.50.0-26-ga8527d2
FROM ghcr.io/pipe-cd/piped-base-okd@sha256:da9bd5a1dae3aa5c2df4baba81ff836ba4a55159d85984605549ef2d1f136895

COPY --from=builder /app/.artifacts/piped /usr/local/bin/piped

ENTRYPOINT ["piped"]
Loading