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

chore: added multistage using a builder with node modules cached. #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
52 changes: 52 additions & 0 deletions .github/workflows/build-builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Copyright (C) 2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

name: build-builder

on:
push:
branches:
- main

jobs:
build-and-push-image:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 #v2.13
with:
image: ghcr.io/${{ github.repository }}-builder
tags: latest ${{ github.sha }}
containerfiles: |
./oci/Containerfile.builder

- name: Push To Registry
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c #v2.8
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
84 changes: 84 additions & 0 deletions .github/workflows/build-extension.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# Copyright (C) 2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

name: build-extension

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
name: build
runs-on: ubuntu-24.04
env:
VERSION: "latest"
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set extension image name
if: github.event_name == 'pull_request'
run: echo "VERSION=pr-${{ github.event.number }}" >> $GITHUB_ENV

- name: Build extension
env:
IMG: ghcr.io/crc-org/podman-desktop-extension-macadam:${VERSION}
shell: bash
run: |
podman build -t ${IMG} -f oci/Containerfile.multistage .
podman save -m -o podman-desktop-extension-macadam.tar ${IMG}
echo ${IMG} > podman-desktop-extension-macadam.image

- name: Upload extension oci flatten images
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: podman-desktop-extension-macadam
path: podman-desktop-extension-macadam*

push:
name: push
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Download extension oci flatten images
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: podman-desktop-extension-macadam

- name: Log in to ghcr.io
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1.7
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image for Release
shell: bash
run: |
podman load -i podman-desktop-extension-macadam.tar
podman push ghcr.io/crc-org/podman-desktop-extension-macadam:latest




61 changes: 61 additions & 0 deletions .github/workflows/push-extension-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Copyright (C) 2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

name: push-extension-pr

on:
workflow_run:
workflows:
- build-extension
types:
- completed

jobs:
push:
name: push
if: |
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Download extension oci flatten images
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: podman-desktop-extension-macadam
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: Get image
shell: bash
run: |
echo "IMAGE=$(cat podman-desktop-extension-macadam.image)" >> "$GITHUB_ENV"

- name: Log in to ghcr.io
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1.7
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image for Release
shell: bash
run: |
podman load -i podman-desktop-extension-macadam.tar
podman push ${IMAGE}
20 changes: 0 additions & 20 deletions Containerfile

This file was deleted.

24 changes: 24 additions & 0 deletions oci/Containerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright (C) 2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

FROM registry.access.redhat.com/ubi9/nodejs-20

COPY package.json .

RUN npm i -g [email protected] \
&& npm install yarn --global \
&& yarn --frozen-lockfile --network-timeout 180000
37 changes: 37 additions & 0 deletions oci/Containerfile.multistage
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright (C) 2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

FROM ghcr.io/crc-org/podman-desktop-extension-macadam-builder:latest AS builder

COPY . .

RUN yarn --network-timeout 180000 \
&& yarn build

FROM scratch

LABEL org.opencontainers.image.title="Macadam extension" \
org.opencontainers.image.description="Example of Macadam extension" \
org.opencontainers.image.vendor="podman-desktop" \
io.podman-desktop.api.version=">= 1.10.0"

COPY package.json /extension/
COPY LICENSE /extension/
COPY icon.png /extension/
COPY README.md /extension/
COPY --from=builder /opt/app-root/src/dist /extension/dist
COPY --from=builder /opt/app-root/src/node_modules/ssh2/ /extension/node_modules/ssh2