diff --git a/.github/workflows/docker-publish-kasm.yml b/.github/workflows/docker-publish-kasm.yml index 882d6869..d97dbf6f 100644 --- a/.github/workflows/docker-publish-kasm.yml +++ b/.github/workflows/docker-publish-kasm.yml @@ -9,141 +9,21 @@ on: paths: - "libs/kasm/**" - ".github/workflows/docker-publish-kasm.yml" + - ".github/workflows/docker-reusable-publish.yml" pull_request: paths: - "libs/kasm/**" - ".github/workflows/docker-publish-kasm.yml" - - -env: - IMAGE_NAME: cua-ubuntu - DOCKER_HUB_ORG: trycua + - ".github/workflows/docker-reusable-publish.yml" jobs: - build-and-push: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - platform: - - linux/amd64 - - linux/arm64 - # todo unsupported base image - # - windows/amd64 - # - darwin/amd64 - # - darwin/arm64 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Prepare platform tag - id: platform - run: | - # Convert platform (e.g., linux/amd64) to a valid tag suffix (e.g., linux-amd64) - PLATFORM_TAG=$(echo "${{ matrix.platform }}" | sed 's/\//-/g') - echo "tag=${PLATFORM_TAG}" >> $GITHUB_OUTPUT - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: trycua - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - - name: Extract metadata (PR) - if: github.event_name == 'pull_request' - id: meta-pr - uses: docker/metadata-action@v5 - with: - images: ${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value=${{ github.sha }} - - - name: Extract metadata (main branch) - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' - id: meta-main - uses: docker/metadata-action@v5 - with: - images: ${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value=latest - - - name: Extract metadata (semantic version tag) - if: startsWith(github.ref, 'refs/tags/docker-kasm-v') - id: meta-semver - uses: docker/metadata-action@v5 - with: - images: ${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}},prefix=docker-kasm-v - type=semver,pattern={{major}}.{{minor}},prefix=docker-kasm-v - type=semver,pattern={{major}},prefix=docker-kasm-v - type=raw,value=latest - - - name: Build and push Docker image (PR) - if: github.event_name == 'pull_request' - uses: docker/build-push-action@v5 - with: - context: ./libs/kasm - file: ./libs/kasm/Dockerfile - push: true - tags: ${{ steps.meta-pr.outputs.tags }} - labels: ${{ steps.meta-pr.outputs.labels }} - platforms: ${{ matrix.platform }} - cache-from: | - type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }} - type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:latest - cache-to: type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }},mode=max - - - name: Build and push Docker image (main branch) - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' - uses: docker/build-push-action@v5 - with: - context: ./libs/kasm - file: ./libs/kasm/Dockerfile - push: true - tags: ${{ steps.meta-main.outputs.tags }} - labels: ${{ steps.meta-main.outputs.labels }} - platforms: ${{ matrix.platform }} - cache-from: | - type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }} - type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:latest - cache-to: type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }},mode=max - - - name: Build and push Docker image (semantic version tag) - if: startsWith(github.ref, 'refs/tags/docker-kasm-v') - uses: docker/build-push-action@v5 - with: - context: ./libs/kasm - file: ./libs/kasm/Dockerfile - push: true - tags: ${{ steps.meta-semver.outputs.tags }} - labels: ${{ steps.meta-semver.outputs.labels }} - platforms: ${{ matrix.platform }} - cache-from: | - type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }} - type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:latest - cache-to: type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.IMAGE_NAME }}:buildcache-${{ steps.platform.outputs.tag }},mode=max - - - name: Image digest - if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/docker-kasm-v') - run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - echo "Image pushed with digest ${{ steps.meta-pr.outputs.digest }}" - elif [[ "${{ github.ref }}" == refs/tags/docker-kasm-v* ]]; then - echo "Image pushed with digest ${{ steps.meta-semver.outputs.digest }}" - else - echo "Image pushed with digest ${{ steps.meta-main.outputs.digest }}" - fi - - - name: print image tags - run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - echo "Image tags: ${{ steps.meta-pr.outputs.tags }}" - elif [[ "${{ github.ref }}" == refs/tags/docker-kasm-v* ]]; then - echo "Image tags: ${{ steps.meta-semver.outputs.tags }}" - else - echo "Image tags: ${{ steps.meta-main.outputs.tags }}" - fi + publish: + uses: ./.github/workflows/docker-reusable-publish.yml + with: + image_name: cua-ubuntu + context_dir: libs/kasm + dockerfile_path: Dockerfile + tag_prefix: docker-kasm-v + docker_hub_org: trycua + secrets: + DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} diff --git a/.github/workflows/docker-publish-xfce.yml b/.github/workflows/docker-publish-xfce.yml new file mode 100644 index 00000000..fa64849e --- /dev/null +++ b/.github/workflows/docker-publish-xfce.yml @@ -0,0 +1,29 @@ +name: Build and Publish CUA XFCE Container + +on: + push: + branches: + - main + tags: + - "docker-xfce-v*.*.*" + paths: + - "libs/xfce/**" + - ".github/workflows/docker-publish-xfce.yml" + - ".github/workflows/docker-reusable-publish.yml" + pull_request: + paths: + - "libs/xfce/**" + - ".github/workflows/docker-publish-xfce.yml" + - ".github/workflows/docker-reusable-publish.yml" + +jobs: + publish: + uses: ./.github/workflows/docker-reusable-publish.yml + with: + image_name: cua-xfce + context_dir: libs/xfce + dockerfile_path: Dockerfile + tag_prefix: docker-xfce-v + docker_hub_org: trycua + secrets: + DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} diff --git a/.github/workflows/docker-reusable-publish.yml b/.github/workflows/docker-reusable-publish.yml new file mode 100644 index 00000000..3472883f --- /dev/null +++ b/.github/workflows/docker-reusable-publish.yml @@ -0,0 +1,155 @@ +name: Reusable Docker Publish Workflow + +on: + workflow_call: + inputs: + image_name: + description: "Name of the Docker image (e.g. cua-ubuntu, cua-xfce)" + required: true + type: string + context_dir: + description: "Directory containing the Dockerfile relative to workspace root (e.g. libs/kasm, libs/xfce)" + required: true + type: string + dockerfile_path: + description: "Path to Dockerfile relative to context_dir (e.g. Dockerfile)" + required: false + type: string + default: "Dockerfile" + tag_prefix: + description: "Prefix for semantic version tags (e.g. docker-kasm-v, docker-xfce-v)" + required: true + type: string + docker_hub_org: + description: "Docker Hub organization name" + required: false + type: string + default: "trycua" + secrets: + DOCKER_HUB_TOKEN: + required: true + +jobs: + build-and-push: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm64 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Prepare platform tag + id: platform + run: | + # Convert platform (e.g., linux/amd64) to a valid tag suffix (e.g., linux-amd64) + PLATFORM_TAG=$(echo "${{ matrix.platform }}" | sed 's/\//-/g') + echo "tag=${PLATFORM_TAG}" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.docker_hub_org }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Extract metadata (PR) + if: github.event_name == 'pull_request' + id: meta-pr + uses: docker/metadata-action@v5 + with: + images: ${{ inputs.docker_hub_org }}/${{ inputs.image_name }} + tags: | + type=raw,value=${{ github.sha }} + + - name: Extract metadata (main branch) + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + id: meta-main + uses: docker/metadata-action@v5 + with: + images: ${{ inputs.docker_hub_org }}/${{ inputs.image_name }} + tags: | + type=raw,value=latest + + - name: Extract metadata (semantic version tag) + if: startsWith(github.ref, format('refs/tags/{0}', inputs.tag_prefix)) + id: meta-semver + uses: docker/metadata-action@v5 + with: + images: ${{ inputs.docker_hub_org }}/${{ inputs.image_name }} + tags: | + type=semver,pattern={{version}},prefix=${{ inputs.tag_prefix }} + type=semver,pattern={{major}}.{{minor}},prefix=${{ inputs.tag_prefix }} + type=semver,pattern={{major}},prefix=${{ inputs.tag_prefix }} + type=raw,value=latest + + - name: Build and push Docker image (PR) + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v5 + with: + context: ./${{ inputs.context_dir }} + file: ./${{ inputs.context_dir }}/${{ inputs.dockerfile_path }} + push: true + tags: ${{ steps.meta-pr.outputs.tags }} + labels: ${{ steps.meta-pr.outputs.labels }} + platforms: ${{ matrix.platform }} + cache-from: | + type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }} + type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:latest + cache-to: type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }},mode=max + + - name: Build and push Docker image (main branch) + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + uses: docker/build-push-action@v5 + with: + context: ./${{ inputs.context_dir }} + file: ./${{ inputs.context_dir }}/${{ inputs.dockerfile_path }} + push: true + tags: ${{ steps.meta-main.outputs.tags }} + labels: ${{ steps.meta-main.outputs.labels }} + platforms: ${{ matrix.platform }} + cache-from: | + type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }} + type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:latest + cache-to: type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }},mode=max + + - name: Build and push Docker image (semantic version tag) + if: startsWith(github.ref, format('refs/tags/{0}', inputs.tag_prefix)) + uses: docker/build-push-action@v5 + with: + context: ./${{ inputs.context_dir }} + file: ./${{ inputs.context_dir }}/${{ inputs.dockerfile_path }} + push: true + tags: ${{ steps.meta-semver.outputs.tags }} + labels: ${{ steps.meta-semver.outputs.labels }} + platforms: ${{ matrix.platform }} + cache-from: | + type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }} + type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:latest + cache-to: type=registry,ref=${{ inputs.docker_hub_org }}/${{ inputs.image_name }}:buildcache-${{ steps.platform.outputs.tag }},mode=max + + - name: Image digest + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || startsWith(github.ref, format('refs/tags/{0}', inputs.tag_prefix)) + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + echo "Image pushed with digest ${{ steps.meta-pr.outputs.digest }}" + elif [[ "${{ github.ref }}" == refs/tags/${{ inputs.tag_prefix }}* ]]; then + echo "Image pushed with digest ${{ steps.meta-semver.outputs.digest }}" + else + echo "Image pushed with digest ${{ steps.meta-main.outputs.digest }}" + fi + + - name: print image tags + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + echo "Image tags: ${{ steps.meta-pr.outputs.tags }}" + elif [[ "${{ github.ref }}" == refs/tags/${{ inputs.tag_prefix }}* ]]; then + echo "Image tags: ${{ steps.meta-semver.outputs.tags }}" + else + echo "Image tags: ${{ steps.meta-main.outputs.tags }}" + fi diff --git a/libs/docker-xfce/.dockerignore b/libs/xfce/.dockerignore similarity index 100% rename from libs/docker-xfce/.dockerignore rename to libs/xfce/.dockerignore diff --git a/libs/docker-xfce/.gitignore b/libs/xfce/.gitignore similarity index 100% rename from libs/docker-xfce/.gitignore rename to libs/xfce/.gitignore diff --git a/libs/docker-xfce/Dockerfile b/libs/xfce/Dockerfile similarity index 100% rename from libs/docker-xfce/Dockerfile rename to libs/xfce/Dockerfile diff --git a/libs/docker-xfce/README.md b/libs/xfce/README.md similarity index 100% rename from libs/docker-xfce/README.md rename to libs/xfce/README.md diff --git a/libs/docker-xfce/src/scripts/resize-display.sh b/libs/xfce/src/scripts/resize-display.sh similarity index 100% rename from libs/docker-xfce/src/scripts/resize-display.sh rename to libs/xfce/src/scripts/resize-display.sh diff --git a/libs/docker-xfce/src/scripts/start-computer-server.sh b/libs/xfce/src/scripts/start-computer-server.sh similarity index 100% rename from libs/docker-xfce/src/scripts/start-computer-server.sh rename to libs/xfce/src/scripts/start-computer-server.sh diff --git a/libs/docker-xfce/src/scripts/start-novnc.sh b/libs/xfce/src/scripts/start-novnc.sh similarity index 100% rename from libs/docker-xfce/src/scripts/start-novnc.sh rename to libs/xfce/src/scripts/start-novnc.sh diff --git a/libs/docker-xfce/src/scripts/start-vnc.sh b/libs/xfce/src/scripts/start-vnc.sh similarity index 100% rename from libs/docker-xfce/src/scripts/start-vnc.sh rename to libs/xfce/src/scripts/start-vnc.sh diff --git a/libs/docker-xfce/src/scripts/xstartup.sh b/libs/xfce/src/scripts/xstartup.sh similarity index 100% rename from libs/docker-xfce/src/scripts/xstartup.sh rename to libs/xfce/src/scripts/xstartup.sh diff --git a/libs/docker-xfce/src/supervisor/supervisord.conf b/libs/xfce/src/supervisor/supervisord.conf similarity index 100% rename from libs/docker-xfce/src/supervisor/supervisord.conf rename to libs/xfce/src/supervisor/supervisord.conf diff --git a/libs/docker-xfce/src/xfce-config/helpers.rc b/libs/xfce/src/xfce-config/helpers.rc similarity index 100% rename from libs/docker-xfce/src/xfce-config/helpers.rc rename to libs/xfce/src/xfce-config/helpers.rc diff --git a/libs/docker-xfce/src/xfce-config/xfce4-session.xml b/libs/xfce/src/xfce-config/xfce4-session.xml similarity index 100% rename from libs/docker-xfce/src/xfce-config/xfce4-session.xml rename to libs/xfce/src/xfce-config/xfce4-session.xml