Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
comminutus committed Jan 22, 2024
0 parents commit 6b542ab
Show file tree
Hide file tree
Showing 9 changed files with 1,003 additions and 0 deletions.
137 changes: 137 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: CI

on:
schedule:
- cron: 0 3 * * *
push:
branches:
- master
tags:
- v*.*.*
pull_request:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}


jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3 #v3.1.1
with:
cosign-release: 'v2.1.1'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ github.sha }}
type=edge,branch=master
type=semver,pattern={{version}},prefix=v
type=semver,pattern={{major}}.{{minor}},prefix=v
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }},prefix=v
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5 # v5.0.0
with:
context: .
file: Containerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

vulnerability-scan:
name: Vulnerability Scan
needs: build
runs-on: ubuntu-latest
steps:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
format: template
template: '@/contrib/sarif.tpl'
output: trivy-results.sarif
# severity: 'CRITICAL,HIGH'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: trivy-results.sarif

tagged-release:
name: Tagged Release
needs: build
runs-on: ubuntu-latest

steps:
- uses: marvinpinto/action-automatic-releases@v1.2.1
if: |
startsWith(github.ref, 'refs/tags/v') &&
github.event_name == 'push'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"cSpell.words": [
"aquasecurity",
"Buildx",
"Chezmoi",
"codeql",
"comminutus",
"Containerfile",
"Distrobox",
"fulcio",
"fwupdmgr",
"marvinpinto",
"ostree",
"Rekor",
"sarif",
"sigstore",
"Trivy"
]
}
82 changes: 82 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
ARG base_tag=39
ARG base_image=registry.fedoraproject.org/fedora-toolbox
FROM ${base_image}:${base_tag}

RUN dnf update -y && dnf upgrade -y

# Reinstall some packages to get man pages back
RUN dnf install -y man

RUN dnf reinstall -y \
authselect \
authselect-libs \
ca-certificates \
cracklib-runtime \
crypto-policies \
expat \
filesystem \
file-libs \
ima-evm-utils \
keyutils-libs \
libarchive \
libpwquality \
libsemanage \
openldap \
pcre2-syntax \
shadow-utils

RUN dnf install -y \
bash-completion \
bind-utils \
jq \
git \
gitk \
git-lfs \
gnupg \
info \
iproute \
iputils \
make \
man \
netcat \
net-tools \
nmap \
openssl \
traceroute \
unzip \
vim-enhanced \
wget \
which

# Install host-spawn. A modified version if it is installed already in Distrobox
# via distrobox-host-exec, however it doesn't have the '-no-pty' aargument that
# host-spawn does, which is necessasry for running some Flatpak programs.
RUN export host_spawn_version=$(curl -sL "https://api.github.com/repos/1player/host-spawn/releases/latest" | jq -r ".tag_name") && \
curl -fsLSo /tmp/host-spawn "https://github.com/1player/host-spawn/releases/download/${host_spawn_version}/host-spawn-$(uname -m)" && \
mv /tmp/host-spawn /usr/bin/ && \
chmod +x /usr/bin/host-spawn
COPY container_bin/* /usr/local/bin
RUN chmod +x /usr/local/bin/*

RUN ln -s /usr/bin/host-spawn-no-pty /usr/local/bin/com.vscodium.codium && \
ln -s /usr/bin/host-spawn /usr/local/bin/distrobox && \
ln -s /usr/bin/host-spawn /usr/local/bin/fwupdmgr && \
ln -s /usr/bin/host-spawn-no-pty /usr/local/bin/org.vim.Vim && \
ln -s /usr/bin/host-spawn /usr/local/bin/podman && \
ln -s /usr/bin/host-spawn /usr/local/bin/rpm-ostree && \
ln -s /usr/bin/host-spawn /usr/local/bin/systemctl

# starship
ARG nerd_font_name=IntoneMono
ARG github_api=https://api.github.com
ARG repo=ryanoasis/nerd-fonts
RUN curl -sS https://starship.rs/install.sh | sh -s -- -y

# chezmoi
RUN sh -c "$(curl -fsLS get.chezmoi.io)"

# trivy
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.48.3

# cleanup
RUN dnf clean all
Loading

0 comments on commit 6b542ab

Please sign in to comment.