Skip to content

Commit f4aec20

Browse files
committed
init
1 parent 96adbc6 commit f4aec20

File tree

3 files changed

+116
-2
lines changed

3 files changed

+116
-2
lines changed

.github/workflows/build.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Build & Push Image
2+
'on':
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
environment: prod
11+
permissions:
12+
id-token: write
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v4
18+
19+
- name: Generate build version
20+
run: |
21+
echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
22+
echo "commit=$(git rev-parse --short=8 HEAD)" >> $GITHUB_OUTPUT
23+
echo "currdate=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT
24+
id: version
25+
26+
- name: Extract metadata (tags, labels) for Docker
27+
id: meta
28+
uses: docker/metadata-action@v5
29+
with:
30+
images: |
31+
ghcr.io/${{ github.repository_owner }}/deck-web-base
32+
tags: |
33+
type=raw,value=${{ steps.version.outputs.branch }}
34+
type=raw,value=${{ steps.version.outputs.commit }}
35+
flavor: latest=true
36+
37+
- name: Generate build cache tag
38+
run: |
39+
echo "ghcr=ghcr.io/${{ github.repository_owner }}/deck-web-base:buildcache" >> $GITHUB_OUTPUT
40+
id: buildcache
41+
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v3
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v3
47+
with:
48+
driver-opts: |
49+
image=moby/buildkit:latest
50+
51+
- name: Login to GitHub Container Registry
52+
uses: docker/login-action@v3
53+
with:
54+
registry: ghcr.io
55+
username: ${{ github.repository_owner }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Build and Push Docker image
59+
id: docker_build
60+
uses: docker/build-push-action@v6
61+
with:
62+
context: .
63+
file: ./Dockerfile
64+
push: true
65+
tags: ${{ steps.meta.outputs.tags }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
cache-from: type=registry,ref=${{ steps.buildcache.outputs.ghcr }}
68+
cache-to: type=registry,ref=${{ steps.buildcache.outputs.ghcr }},mode=max

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM php:8.1-cli AS base
2+
3+
# Install dependencies
4+
RUN apt-get update -y && apt-get install -y --no-install-recommends \
5+
apt-utils curl git zip unzip libbz2-dev openssl gcc make autoconf \
6+
libc6-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev libicu-dev \
7+
zlib1g-dev libzip-dev pkg-config && \
8+
apt-get clean -y && rm -rf /var/lib/apt/lists/*
9+
10+
# Install PHP extensions via PECL
11+
RUN pecl install igbinary-3.2.15 && \
12+
pecl install --configureoptions='enable-redis-igbinary="yes"' redis-6.2.0 && \
13+
pecl install protobuf-4.27.2 grpc-1.64.1 && \
14+
rm -rf /tmp/pear
15+
16+
# Install PHP extensions via source (php-ext-lz4)
17+
RUN git clone --recursive --depth=1 https://github.com/kjdev/php-ext-lz4.git /tmp/php-ext-lz4 && \
18+
cd /tmp/php-ext-lz4 && \
19+
phpize && ./configure && make && make install && \
20+
rm -rf /tmp/php-ext-lz4
21+
22+
# Install PHP extensions via docker-php-ext-install
23+
RUN docker-php-ext-install bcmath bz2 mysqli pdo_mysql pcntl zip && \
24+
docker-php-ext-configure gd && docker-php-ext-install -j$(nproc) gd && \
25+
docker-php-ext-configure intl && docker-php-ext-install intl
26+
27+
# Install PHP-SPX
28+
RUN git clone --recursive --depth=1 https://github.com/NoiseByNorthwest/php-spx.git /tmp/php-spx && \
29+
cd /tmp/php-spx && \
30+
phpize && ./configure && make && make install && \
31+
rm -rf /tmp/php-spx
32+
33+
# Install and configure Xdebug
34+
RUN pecl install xdebug && docker-php-ext-enable xdebug && \
35+
echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
36+
echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
37+
rm -rf /tmp/pear

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
# php-ext-builder
2-
Dockerfile and image for custom docker build
1+
# php8.1-cli build stage using Docker
2+
Build stage for php8.1-cli with custom extension.
3+
4+
# Installed extension
5+
- Igbinary
6+
- Redis
7+
- Protobuf
8+
- gRPC
9+
- PHP-SPX
10+
- Xdebug
11+
- PHP-LZ4

0 commit comments

Comments
 (0)