Skip to content

Commit

Permalink
feat: include a demo extension
Browse files Browse the repository at this point in the history
allow to setup the podify containers using Podman Desktop
  • Loading branch information
benoitf committed Oct 18, 2023
1 parent e2231b8 commit 3914f34
Show file tree
Hide file tree
Showing 15 changed files with 3,343 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/build-publish-demo-extension.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
#
# Copyright (C) 2023 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 and publish the demo extension

on:
push:
branches:
- main
paths:
- "extension/**"
workflow_dispatch:

jobs:
build:
name: Build image
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Install qemu dependency
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Build Extension Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: podman-desktop-extension
tags: latest ${{ github.sha }}
containerfiles: |
./extension/Dockerfile
context: ./extension
archs: amd64, arm64

- name: Echo Outputs
run: |
echo "Image: ${{ steps.build-image.outputs.image }}"
echo "Tags: ${{ steps.build-image.outputs.tags }}"
echo "Tagged Image: ${{ steps.build-image.outputs.image-with-tag }}"
- name: Log in to Red Hat Registry
uses: redhat-actions/podman-login@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/podman-desktop-demo
69 changes: 69 additions & 0 deletions .github/workflows/pr-check-demo-extension.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
#
# Copyright (C) 2023 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: Pull Request check of the demo extension

on:
pull_request:
paths:
- "extension/**"

jobs:
build:
name: Check demo extension
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: 18

- uses: actions/setup-python@v4
with:
python-version: "3.x"

- uses: actions/cache@v3
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: Execute yarn
run: yarn --frozen-lockfile
working-directory: ./extension

- name: Run linter
run: yarn lint:check
working-directory: ./extension

- name: Run formatter
run: yarn format:check
working-directory: ./extension

- name: Run typecheck
run: yarn typecheck
working-directory: ./extension

- name: yarn
working-directory: ./extension
run: |
yarn --frozen-lockfile --network-timeout 180000
79 changes: 79 additions & 0 deletions extension/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"root": true,
"env": {
"es2021": true,
"node": true,
"browser": false
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:etc/recommended",
"plugin:sonarjs/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"warnOnUnsupportedTypeScriptVersion": false,
"project": ["./tsconfig.json"]
},
"settings": {
"import/resolver": {
"typescript": true,
"node": true,
"eslint-import-resolver-custom-alias": {
"alias": {
"/@": "./src",
"/@gen": "./src-generated"
},
"extensions": [".ts"]
}
}
},
"plugins": ["@typescript-eslint", "sonarjs", "etc", "redundant-undefined", "no-null"],
"ignorePatterns": ["node_modules/**", "**/dist/**"],
"rules": {
"eqeqeq": "error",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-explicit-any": "error",
"prefer-promise-reject-errors": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"no-null/no-null": "error",

/**
* Having a semicolon helps the optimizer interpret your code correctly.
* This avoids rare errors in optimized code.
* @see https://twitter.com/alex_kozack/status/1364210394328408066
*/
"semi": ["error", "always"],
/**
* This will make the history of changes in the hit a little cleaner
*/
"comma-dangle": ["warn", "always-multiline"],
/**
* Just for beauty
*/
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"import/no-duplicates": "error",
"import/no-unresolved": "off",
"import/default": "off",
"import/no-named-as-default-member": "off",
"import/no-named-as-default": "off",
"sonarjs/cognitive-complexity": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-empty-collection": "off",
"sonarjs/no-small-switch": "off",
"etc/no-commented-out-code": "error",
"etc/no-deprecated": "off",
"redundant-undefined/redundant-undefined": "error",
"import/no-extraneous-dependencies": "error"
}
}
5 changes: 5 additions & 0 deletions extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
builtin
dist
*.cdix
.eslintcache
8 changes: 8 additions & 0 deletions extension/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"bracketSameLine": true,
"singleQuote": true,
"arrowParens": "avoid",
"printWidth": 120,
"trailingComma": "all"
}

44 changes: 44 additions & 0 deletions extension/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Copyright (C) 2023 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-18:latest AS builder

USER root
RUN npm install -g yarn

COPY . /extension
WORKDIR /extension

RUN chgrp -R 0 /extension && chmod -R g+rwX /extension

USER 1001

RUN yarn install && yarn build

RUN mkdir /tmp/extension \
&& cp /extension/package.json \
/extension/LICENSE \
/extension/README.md \
/extension/icon.png /tmp/extension \
&& cp -r /extension/dist /tmp/extension/dist

FROM scratch
LABEL org.opencontainers.image.title="Podman Desktop Demo" \
org.opencontainers.image.description="Demo Podify scenario" \
org.opencontainers.image.vendor="redhat" \
io.podman-desktop.api.version=">= 1.5.0"
COPY --from=builder /tmp/extension/ /extension

0 comments on commit 3914f34

Please sign in to comment.