feat: set up ubuntu base image build
Some checks failed
/ build-images (ubuntu-2204) (push) Has been cancelled
Some checks failed
/ build-images (ubuntu-2204) (push) Has been cancelled
ci: tag image as latest
This commit is contained in:
parent
9a81a5d9a7
commit
5a4b129e42
5 changed files with 94 additions and 0 deletions
27
.forgejo/workflows/ci.yml
Normal file
27
.forgejo/workflows/ci.yml
Normal 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
|
33
images/ubuntu-2204/Dockerfile
Normal file
33
images/ubuntu-2204/Dockerfile
Normal 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
|
3
images/ubuntu-2204/files/registries.conf
Normal file
3
images/ubuntu-2204/files/registries.conf
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[[registry]]
|
||||||
|
insecure = true
|
||||||
|
location = "host.containers.internal:5000"
|
19
script/build-image.sh
Executable file
19
script/build-image.sh
Executable 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
12
script/get-tag.sh
Executable 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"
|
Loading…
Reference in a new issue