feat: set up ubuntu base image build
All checks were successful
/ build-images (ubuntu-2204) (push) Successful in 2m32s

This commit is contained in:
Marc 2024-07-20 15:38:21 -04:00
parent 9a81a5d9a7
commit 3733e43428
Signed by: marc
GPG key ID: 048E042F22B5DC79
5 changed files with 83 additions and 0 deletions

20
.forgejo/workflows/ci.yml Normal file
View file

@ -0,0 +1,20 @@
on:
push:
tags:
- "v*"
env:
REGISTRY_ENDPOINT: host.containers.internal:5000
jobs:
build-images:
runs-on: ubuntu-latest
strategy:
matrix:
image-name: ['ubuntu-2204']
steps:
- uses: actions/checkout@v4
- name: Login to Registry
run: podman login -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_TOKEN }} ${{ env.REGISTRY_ENDPOINT }}
- name: Build image (${{ matrix.image-name }})
run: ./script/build-image.sh ${{ matrix.image-name }}

View file

@ -0,0 +1,33 @@
FROM ubuntu:22.04 as skeleton
ENV NODE_VERSION="20.12.2"
RUN apt update && \
apt upgrade -y && \
apt install -y \
curl \
podman \
jq \
git \
xz-utils \
ca-certificates \
unzip \
--no-install-recommends \
--autoremove
FROM skeleton as build
WORKDIR tmp
RUN curl https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz \
--output /tmp/node-v$NODE_VERSION-linux-x64.tar.xz && \
tar -xf /tmp/node-v$NODE_VERSION-linux-x64.tar.xz
FROM skeleton as runner
WORKDIR /runner
COPY --from=build /tmp/node-v$NODE_VERSION-linux-x64/bin/* /bin/
COPY --from=build /tmp/node-v$NODE_VERSION-linux-x64/lib/* /lib/
COPY ./files/registries.conf /etc/containers/registries.conf

View file

@ -0,0 +1,3 @@
[[registry]]
insecure = true
location = "host.containers.internal:5000"

15
script/build-image.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
image_name=$1
if [[ -z $image_name ]]; then
echo "An image name must be provided."
return
fi
image_tag=$(./script/get-tag.sh)
(
cd "images/$image_name"
podman build -t "$image_name:$image_tag" -f ./Dockerfile
)

12
script/get-tag.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
has_changes=$(git status --short)
head_sha=$(git rev-parse --short HEAD)
tag=$head_sha
if [[ -n $has_changes ]]; then
tag="$tag-dev"
fi
echo "$tag"