Compare commits
6 Commits
e39b25e0d4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d180466a2 | |||
| 72e7158aa3 | |||
| 55ae125cab | |||
| 32eb679d9a | |||
| 63a1d8423e | |||
| b7068375e8 |
51
.gitea/workflows/registry.yml
Normal file
51
.gitea/workflows/registry.yml
Normal 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
3
Dockerfile
Normal 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
|
||||
@@ -7,4 +7,6 @@ return [
|
||||
'author_link' => 'https://danb.me',
|
||||
'license_link' => 'https://creativecommons.org/publicdomain/zero/1.0/',
|
||||
'license_text' => 'CC0 - Public Domain',
|
||||
];
|
||||
];
|
||||
|
||||
?>
|
||||
@@ -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,
|
||||
) {}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user