Skip to content

Commit

Permalink
Merge pull request #5 from jumpstarter-dev/devspace
Browse files Browse the repository at this point in the history
Website devspace
  • Loading branch information
mangelajo authored Nov 3, 2024
2 parents 2eeb188 + bd91c7a commit 028a14c
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .devfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
schemaVersion: 2.3.0
metadata:
name: jumpstarter-website-dev
icon: https://jumpstarter.dev/jumpstarter.svg
tags:
- hugo
- website
language: Python
projects:
- name: jumpstarter
git:
remotes:
origin: https://github.com/jumpstarter-dev/website.git
components:
- name: runtime
container:
image: quay.io/jumpstarter-dev/jumpstarter-website-devspace:latest
endpoints:
- name: website
targetPort: 1313
protocol: http
mountSources: true

commands:
- id: serve-website
exec:
component: runtime
commandLine: hugo serve
19 changes: 19 additions & 0 deletions .devfile/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM quay.io/devfile/base-developer-image:ubi9-latest
LABEL maintainer="jumpstarter.dev"

LABEL name="devfile/udi9/jumpstarter-website"

#labels for container catalog
LABEL summary="devfile jumpstarter website developer image"
LABEL description="Devspaces image for maintaining the website"
LABEL io.k8s.display-name="jumpstarter-website-developer"


# Install required packages
USER root
RUN dnf install -y nodejs npm git golang jq && dnf clean all
COPY .devfile/install_hugo.sh /tmp/install_hugo.sh
RUN /tmp/install_hugo.sh

USER 10001

28 changes: 28 additions & 0 deletions .devfile/install_hugo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

set -ex

ARCH=$(uname -m)

case $ARCH in
x86_64)
ARCH="amd64"
;;
aarch64)
ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac

URL=$(curl https://api.github.com/repos/gohugoio/hugo/releases/latest -s | \
jq -r ".assets[] | select(.name | test(\"linux\")) | .browser_download_url" | \
grep .tar.gz | \
grep -v extended | \
grep "${ARCH}")

echo $URL
curl -L $URL | tar xvfz - -C /usr/bin hugo

85 changes: 85 additions & 0 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build and push container image
on:
workflow_dispatch:
push:
merge_group:

env:
PUSH: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
REGISTRY: quay.io
QUAY_ORG: quay.io/jumpstarter-dev

jobs:
build-and-push-image:
strategy:
matrix:
image:
- jumpstarter-dev/jumpstarter-website-devspace .devfile/Containerfile
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get image name and container file
run: |
IMAGE="${{ matrix.image }}"
IMAGE_NAME=$(echo $IMAGE | awk '{print $1}')
CONTAINERFILE=$(echo $IMAGE | awk '{print $2}')
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "IMAGE_NAME=${IMAGE_NAME}"
echo "CONTAINERFILE=${CONTAINERFILE}" >> $GITHUB_ENV
echo "CONTAINERFILE=${CONTAINERFILE}"
- name: Get version
run: |
VERSION=$(git describe --tags)
VERSION=${VERSION#v} # remove the leading v prefix for version
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
if: ${{ env.PUSH == 'true' }}
with:
registry: ${{ env.REGISTRY }}
username: jumpstarter-dev+jumpstarter_ci
password: ${{ secrets.QUAY_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ env.CONTAINERFILE }}
push: ${{ env.PUSH }}
tags: ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ env.PUSH == 'true' }}
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: ${{ env.PUSH }}

0 comments on commit 028a14c

Please sign in to comment.