Initial commit
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
2026-02-03 18:27:33 +01:00
commit e1f5165222
6 changed files with 180 additions and 0 deletions

1
.dockerignore Normal file
View File

@@ -0,0 +1 @@
.gitea/

12
.editorconfig Normal file
View File

@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false

View File

@@ -0,0 +1,57 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
env:
REGISTRY: ${{ vars.REGISTRY || 'hub.bundespruefstelle.ch' }}
IMAGE_NAME: ${{ vars.IMAGE_NAME || github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PHP_VERSION=8.4

0
.gitignore vendored Normal file
View File

12
Dockerfile Normal file
View File

@@ -0,0 +1,12 @@
#syntax=docker/dockerfile:1
ARG PHP_VERSION=8.4
FROM wordpress:php${PHP_VERSION} AS upstream
RUN pecl install redis apcu; \
docker-php-ext-enable redis apcu;
FROM upstream AS runtime
WORKDIR /var/www/html

98
README.md Normal file
View File

@@ -0,0 +1,98 @@
# WordPress Docker Image
Custom WordPress Docker image with Redis and APCu extensions for object caching.
## Features
- Based on official `wordpress:php8.4` image
- Redis extension for external object caching
- APCu extension for in-memory caching
## Usage
### Pull from Registry
```bash
docker pull your-registry.com/wordpress:latest
```
### Build Locally
```bash
docker build -t wordpress-custom .
```
### Run
```bash
docker run -d \
-p 8080:80 \
-e WORDPRESS_DB_HOST=db \
-e WORDPRESS_DB_USER=wordpress \
-e WORDPRESS_DB_PASSWORD=secret \
-e WORDPRESS_DB_NAME=wordpress \
wordpress-custom
```
### Docker Compose Example
```yaml
services:
wordpress:
build: .
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: secret
WORDPRESS_DB_NAME: wordpress
depends_on:
- db
- redis
db:
image: mariadb:11
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: secret
redis:
image: redis:7-alpine
```
## Build Arguments
| Argument | Default | Description |
| ------------- | ------- | ------------------ |
| `PHP_VERSION` | `8.4` | PHP version to use |
```bash
docker build --build-arg PHP_VERSION=8.3 -t wordpress-custom .
```
## CI/CD
This repository includes a Gitea Actions workflow that automatically builds and pushes the image.
### Required Secrets
| Secret | Description |
| ------------------- | --------------------------------- |
| `REGISTRY_USERNAME` | Container registry username |
| `REGISTRY_PASSWORD` | Container registry password/token |
### Optional Variables
| Variable | Default | Description |
| ------------ | ------------------- | ---------------------- |
| `REGISTRY` | `gitea.example.com` | Container registry URL |
| `IMAGE_NAME` | Repository name | Custom image name |
### Trigger Events
- Push to `main` or `master` branch
- Version tags (`v*`)
- Pull requests (build only, no push)