Skip to content

Commit

Permalink
CI build testing
Browse files Browse the repository at this point in the history
  - image build 2
  - explore npm cache for qemu npm install stability
  - ci-repo concurrency

Signed-off-by: Scott J Dickerson <[email protected]>
  • Loading branch information
sjd78 committed Sep 12, 2024
1 parent 4edbf72 commit 9f6fd0f
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 21 deletions.
66 changes: 45 additions & 21 deletions .github/workflows/image-build-2.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Multiple Architecture Image Build 2
name: Image Build 2

on:
workflow_dispatch:
Expand All @@ -14,37 +14,55 @@ concurrency:
cancel-in-progress: true

env:
tag: ${{ github.ref == 'refs/heads/main' && 'latest' || github.ref_name }}
tag: ${{ github.ref == 'refs/heads/main' && 'latest1' || github.ref_name }}

# what is normally sent in as input
registry: "quay.io/sdickers"
image_name: "tackle2-ui"
containerfile: "./Dockerfile"
context: "."

architectures: '[ "amd64", "arm64" ]'

extra-args: "--ulimit nofile=4096:4096"

# pre_build_cmd: |
# echo "registry=\"http://localhost:4873\"" >> .npmrc
# pre_build_cmd: |
# echo "registry=https://npm.pkg.github.com" >> .npmrc
# echo "registry=\"http://host.containers.internal:4873\"" >> .npmrc
# echo "registry=\"http://host.docker.internal:4873\"" >> .npmrc

jobs:
# fill-cache:
# runs-on: ubuntu-latest

# # setup a npm mirror server so multiple npm installs can share fetches
# services:
# npm-mirror:
# image: verdaccio/verdaccio:5
# ports:
# - 4873:4873
# volumes:
# -

build:
runs-on: ubuntu-latest

# setup a npm mirror server so multiple npm installs can share fetches
# services:
# npm-mirror:
# image: verdaccio/verdaccio:5
# ports:
# - 4873:4873
services:
npm-mirror:
image: verdaccio/verdaccio:5
ports:
- 4873:4873

strategy:
matrix:
architecture:
- "amd64"
- "arm64"
- "ppc64le"
- "s390x"
architecture: # can't use `env` here.. ${{ fromJson(env.architectures) }}
- amd64
- arm64

# concurrency:
# group: image-build-2-${{ github.ref }}-${{ matrix.architecture }}
# cancel-in-progress: true

steps:
- name: Maximize disk space
Expand All @@ -60,12 +78,17 @@ jobs:
df . -h
- name: Checkout
uses: actions/checkout@main
uses: actions/checkout@v4

- name: Proxy npm registry to the "npm-mirror" service
run: |
echo "registry=\"http://npm-mirror:4873\"" >> .npmrc
- name: Configure QEMU
- name: Setup QEMU to be able to build on ${{ matrix.architecture }}
if: ${{ matrix.architecture != 'amd64' }}
uses: docker/setup-qemu-action@master
with:
platforms: all
platforms: ${{ matrix.architecture }}

- name: Image meta
id: meta
Expand All @@ -81,10 +104,10 @@ jobs:
type=ref,event=pr
type=sha
- name: Run pre build command
shell: bash
run: "${{ env.pre_build_cmd }}"
if: "${{ env.pre_build_cmd != '' }}"
# - name: Run pre build command
# shell: bash
# run: "${{ env.pre_build_cmd }}"
# if: "${{ env.pre_build_cmd != '' }}"

- name: Build Image
id: build
Expand All @@ -96,6 +119,7 @@ jobs:
archs: ${{ matrix.architecture }}
labels: ${{ steps.meta.outputs.labels }}
containerfiles: ${{ env.containerfile }}
context: ${{ env.context }}

- name: Push To Quay
uses: redhat-actions/push-to-registry@main
Expand Down
1 change: 1 addition & 0 deletions hack/npm-caching-proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
storage/
9 changes: 9 additions & 0 deletions hack/npm-caching-proxy/Dockerfile_
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM verdaccio/verdaccio:5

ADD config.yaml /verdaccio/conf/config.yaml

USER root
RUN npm install --global verdaccio-static-token \
&& npm install --global verdaccio-auth-memory

USER $VERDACCIO_USER_UID
20 changes: 20 additions & 0 deletions hack/npm-caching-proxy/build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -xe

#
# Build the project's container image using the npm caching proxy that
# has been setup with run.sh
#

# cd to project root
[[ -e Dockerfile ]] || cd ../..

# TODO: Grab the current project config and replace after the run
npm config set registry "http://host.containers.internal:4873" --location=project
# --env "npm_config_registry=http://host.containers.internal:4873" \

podman build \
--pull \
-t localhost/tackle2-ui:image1 \
.

npm config delete registry --location=project
41 changes: 41 additions & 0 deletions hack/npm-caching-proxy/config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://github.com/verdaccio/verdaccio/blob/5.x/conf/docker.yaml
# https://verdaccio.org/docs/configuration

storage: /verdaccio/storage/data
plugins: /verdaccio/plugins

web:
title: Verdaccio npm cache
login: false

auth:
htpasswd:
file: /verdaccio/storage/htpasswd
algorithm: bcrypt
max_users: -1

uplinks:
npmjs:
url: https://registry.npmjs.org/

packages:
"@*/*":
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs

"**":
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs

server:
keepAliveTimeout: 60

middlewares:
audit:
enabled: true

log: { type: stdout, format: pretty, level: info }
19 changes: 19 additions & 0 deletions hack/npm-caching-proxy/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -xe

#
# userns=keep-id with the uid and gid settings will have podman map
# the uid and gid of the user who runs the container to those uid and
# gid internally so files created on the host belong to the user who
# started the container!
#
podman run \
-it \
--rm \
--name npm-mirror \
--userns=keep-id:uid=10001,gid=65533 \
-p 4873:4873 \
-v ./config:/verdaccio/conf:Z \
-v ./storage:/verdaccio/storage:Z,U \
verdaccio/verdaccio:5 \
$@

0 comments on commit 9f6fd0f

Please sign in to comment.