Compare commits

..

6 Commits

Author SHA1 Message Date
8d180466a2 public/index.php aktualisiert
All checks were successful
release-tag / release-image (push) Successful in 26s
2025-01-01 23:02:44 +00:00
72e7158aa3 config.php.example aktualisiert
All checks were successful
release-tag / release-image (push) Successful in 28s
2025-01-01 22:54:05 +00:00
55ae125cab public/index.php aktualisiert
Some checks failed
release-tag / release-image (push) Has been cancelled
2025-01-01 22:53:46 +00:00
32eb679d9a Dockerfile aktualisiert
All checks were successful
release-tag / release-image (push) Successful in 26s
2025-01-01 22:48:57 +00:00
63a1d8423e .gitea/workflows/registry.yml hinzugefügt
All checks were successful
release-tag / release-image (push) Successful in 42s
2025-01-01 22:38:02 +00:00
b7068375e8 Dockerfile hinzugefügt 2025-01-01 22:36:14 +00:00
4 changed files with 102 additions and 10 deletions

View File

@@ -0,0 +1,51 @@
name: release-tag
on:
push:
branches:
- 'main'
jobs:
release-image:
runs-on: ubuntu-latest
env:
DOCKER_ORG: sendnrw
DOCKER_LATEST: latest
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2
with: # replace it with your local IP
config-inline: |
[registry."git.send.nrw"]
http = true
insecure = true
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: git.send.nrw # replace it with your local IP
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get Meta
id: meta
run: |
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: |
linux/amd64
push: true
tags: | # replace it with your local IP and tags
git.send.nrw/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
git.send.nrw/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }}

3
Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM git.send.nrw/sendnrw/docker_php_84:latest
COPY public /usr/share/nginx/html
COPY config.php.example /usr/share/nginx/config.php

View File

@@ -7,4 +7,6 @@ return [
'author_link' => 'https://danb.me',
'license_link' => 'https://creativecommons.org/publicdomain/zero/1.0/',
'license_text' => 'CC0 - Public Domain',
];
];
?>

View File

@@ -68,6 +68,7 @@ function getCategories(): array {
/**
* Get the thumbnail image uri for the given category.
*/
function getCategoryThumbnail(string $category): string {
$categoryImages = getCategoryImageFiles($category);
$firstImage = $categoryImages[0] ?? '';
@@ -83,6 +84,7 @@ function getCategoryThumbnail(string $category): string {
* Generated a thumbnail for the given image filename withing
* the given category folder.
*/
function generateImageThumbnail(string $category, string $image): void {
$imagePath = buildPath(IMAGES_DIR, $category, $image);
$thumbPath = buildPath(THUMBS_DIR, $category, $image);
@@ -95,18 +97,45 @@ function generateImageThumbnail(string $category, string $image): void {
error("Could not find image at {$imagePath}");
}
if (!str_ends_with(strtolower($imagePath), '.webp')) {
error("Image at {$imagePath} is not webp as expected");
}
$thumbDir = dirname($thumbPath);
if (!file_exists($thumbDir)) {
mkdir($thumbDir);
mkdir($thumbDir, 0777, true);
}
$imageExtension = strtolower(pathinfo($imagePath, PATHINFO_EXTENSION));
switch ($imageExtension) {
case 'webp':
$originalImage = imagecreatefromwebp($imagePath);
break;
case 'jpg':
case 'jpeg':
$originalImage = imagecreatefromjpeg($imagePath);
break;
case 'png':
$originalImage = imagecreatefrompng($imagePath);
break;
default:
error("Unsupported image format: {$imageExtension}");
}
$originalImage = imagecreatefromwebp($imagePath);
$thumbImage = imagescale($originalImage, 1200);
imagewebp($thumbImage, $thumbPath, 50);
switch ($imageExtension) {
case 'webp':
imagewebp($thumbImage, $thumbPath, 50);
break;
case 'jpg':
case 'jpeg':
imagejpeg($thumbImage, $thumbPath, 50);
break;
case 'png':
imagepng($thumbImage, $thumbPath, 6); // Compression level for PNG: 0-9
break;
}
imagedestroy($originalImage);
imagedestroy($thumbImage);
}
/**
@@ -133,7 +162,13 @@ function categoryExists(string $category): bool {
* @return string[]
*/
function getCategoryImageFiles(string $category): array {
$images = glob(buildPath(IMAGES_DIR, $category, '*.webp'));
$extensions = ['webp', 'jpg', 'jpeg', 'png'];
$images = [];
foreach ($extensions as $extension) {
$images = array_merge($images, glob(buildPath(IMAGES_DIR, $category, "*.{$extension}")));
}
return array_map(fn(string $dir) => basename($dir), $images);
}
@@ -231,4 +266,5 @@ class Image {
public string $uri,
public string $thumb,
) {}
}
}
?>