From e1f516522250493fa190c81f489c9b3ab2a5286e Mon Sep 17 00:00:00 2001 From: magdev Date: Tue, 3 Feb 2026 18:27:33 +0100 Subject: [PATCH] Initial commit --- .dockerignore | 1 + .editorconfig | 12 ++++ .gitea/workflows/build-push.yaml | 57 +++++++++++++++++++ .gitignore | 0 Dockerfile | 12 ++++ README.md | 98 ++++++++++++++++++++++++++++++++ 6 files changed, 180 insertions(+) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 .gitea/workflows/build-push.yaml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5d22c83 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.gitea/ \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c1322dc --- /dev/null +++ b/.editorconfig @@ -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 \ No newline at end of file diff --git a/.gitea/workflows/build-push.yaml b/.gitea/workflows/build-push.yaml new file mode 100644 index 0000000..f3fd7e1 --- /dev/null +++ b/.gitea/workflows/build-push.yaml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d3337e9 --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..fe009e6 --- /dev/null +++ b/README.md @@ -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)