feat: set up ubuntu base image build
Some checks failed
/ build-images (ubuntu-2204) (push) Has been cancelled

ci: tag image as latest
This commit is contained in:
Marc 2024-07-20 15:38:21 -04:00
parent 9a81a5d9a7
commit 5a4b129e42
Signed by: marc
GPG key ID: 048E042F22B5DC79
5 changed files with 94 additions and 0 deletions

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

@ -0,0 +1,27 @@
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: Set image metadata
id: image-metadata
run: |
echo "image-tag=$(./script/get-tag.sh)" >> $GITHUB_OUTPUT
echo "full-image-name=${{ matrix.image-name }}:$(./script/get-tag.sh)" >> $GITHUB_OUTPUT
- name: Build image
run: ./script/build-image.sh ${{ matrix.image-name }} ${{ steps.image-metadata.outputs.image-tag }}
- name: Tag image as latest
run: podman tag ${{ steps.image-metadata.outputs.full-image-name }} ${{ matrix.image-name }}:latest

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"

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

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

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"