Skip to content

Commit

Permalink
freeze 8.3 version into branch
Browse files Browse the repository at this point in the history
  • Loading branch information
muhajirinlpu committed Nov 24, 2024
1 parent d44fdf4 commit 0aaac9e
Show file tree
Hide file tree
Showing 27 changed files with 408 additions and 11 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/ci-slim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Docker build for slim variant
on:
push:
branches:
- 8.3
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:

jobs:
build-cli:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USR }}
password: ${{ secrets.GHCR_PAT }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: slim/cli/
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/digital-entropy/dokar-php/cli:8.3-slim

build-fpm:
needs: build-cli
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USR }}
password: ${{ secrets.GHCR_PAT }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: ubuntu/fpm/
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/digital-entropy/dokar-php/fpm:8.3-slim

build-octane:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USR }}
password: ${{ secrets.GHCR_PAT }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: ubuntu/octane/
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/digital-entropy/dokar-php/octane:8.3-slim

build-nginx:
needs: build-fpm
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USR }}
password: ${{ secrets.GHCR_PAT }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: ubuntu/nginx/
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/digital-entropy/dokar-php/nginx:8.3-slim
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml → .github/workflows/ci-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
build-cli:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
-
name: Checkout
Expand All @@ -31,14 +31,14 @@ jobs:
name: Build and push
uses: docker/build-push-action@v6
with:
context: cli/
context: ubuntu/cli/
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/digital-entropy/dokar-php/cli:8.3

build-fpm:
needs: build-cli
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
-
name: Checkout
Expand All @@ -60,13 +60,13 @@ jobs:
name: Build and push
uses: docker/build-push-action@v6
with:
context: fpm/
context: ubuntu/fpm/
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/digital-entropy/dokar-php/fpm:8.3

build-octane:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
-
name: Checkout
Expand All @@ -88,14 +88,14 @@ jobs:
name: Build and push
uses: docker/build-push-action@v6
with:
context: octane/
context: ubuntu/octane/
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/digital-entropy/dokar-php/octane:8.3

build-nginx:
needs: build-fpm
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
-
name: Checkout
Expand All @@ -117,7 +117,7 @@ jobs:
name: Build and push
uses: docker/build-push-action@v6
with:
context: nginx/
context: ubuntu/nginx/
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/digital-entropy/dokar-php/nginx:8.3
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ DOKAR PHP

PHP 8.3 of dokar-php

There is 4 variant in this images.
### There are 4 flavors in this image

| Variant | Description | Usage |
| Flavor | Description | Usage |
| --- | --- | --- |
| Only CLI | Provide only php-cli. This image can be useful to run such as `laravel-horizon, laravel-websocket, tinker`. | `docker pull ghcr.io/digital-entropy/dokar-php/cli:8.3` |
| Only PHP-FPM | Provide php-fpm from php-cli variant. This image listen on `fastcgi 0.0.0.0:9008`. | `docker pull ghcr.io/digital-entropy/dokar-php/fpm:8.3` |
| Only PHP-FPM | Provide php-fpm from php-cli. This image listen on `fastcgi 0.0.0.0:9008`. | `docker pull ghcr.io/digital-entropy/dokar-php/fpm:8.3` |
| With Nginx | Production ready php image that use nginx as web server. This image will serve `/var/www/public` directory. | `docker pull ghcr.io/digital-entropy/dokar-php/nginx:8.3` |
Octane | Crafted for running octane with `swoole` driver. use `DOCKER_WORKERS=` env to define specific worker you need.| `docker pull ghcr.io/digital-entropy/dokar-php/octane:8.3`

> Dokar PHP by default is using Ubuntu image, but we also provide Alpine image.
> You can add `-slim` in tag to use Alpine based image. e.g., `docker pull ghcr.io/digital-entropy/dokar-php/octane:8.3-slim`
26 changes: 26 additions & 0 deletions slim/cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM alpine:3

LABEL org.opencontainers.image.source=https://github.com/digital-entropy/dokar-php
LABEL org.opencontainers.image.branch=8.3

ENV TERM=linux

ENV TZ=UTC

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apk update \
&& apk add --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing gosu \
&& apk add bash curl ca-certificates zip unzip git sqlite libcap libpng-dev \
php83 php83-dev php83-gd php83-curl php83-soap \
php83-sqlite3 php83-pgsql php83-mysqli \
php83-mbstring php83-xml php83-zip php83-bcmath \
php83-intl php83-ldap php83-pecl-igbinary php83-pecl-redis \
composer \
&& apk cache clean \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*

RUN composer global require --quiet --no-ansi laravel/envoy \
&& composer clear-cache --quiet \
&& ln -s /root/.composer/vendor/laravel/envoy/bin/envoy /usr/bin/envoy

18 changes: 18 additions & 0 deletions slim/fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ghcr.io/digital-entropy/dokar-php/cli:8.3-slim

LABEL org.opencontainers.image.source=https://github.com/digital-entropy/dokar-php
LABEL org.opencontainers.image.branch=8.3

# Install FPM
RUN apk update \
&& apk add php83-fpm \
&& apk cache clean \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*

# PHP-FPM packages need a nudge to make them docker-friendly
COPY overrides.conf /etc/php/8.3/fpm/pool.d/z-overrides.conf

# PHP-FPM has really dirty logs, certainly not good for dockerising
# The following startup script contains some magic to clean these up
COPY php-fpm-startup /usr/bin/php-fpm
CMD /usr/bin/php-fpm
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions slim/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ghcr.io/digital-entropy/dokar-php/fpm:8.3-slim

LABEL org.opencontainers.image.source=https://github.com/digital-entropy/dokar-php
LABEL org.opencontainers.image.branch=8.3

RUN apk update \
&& apk add nginx supervisor \
&& apk cache clean \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/* \
&& rm /etc/nginx/http.d/*

RUN mkdir -p /var/www/public

COPY index.php /var/www/public

WORKDIR /var/www

COPY site.conf /etc/nginx/http.d/site.conf

COPY supervisor /etc/supervisor

# Add a non-root user to prevent files being created with root permissions on host machine.
ONBUILD ARG USER_CONTAINER=dokar
ONBUILD ENV USER_CONTAINER=${USER_CONTAINER}
ONBUILD ARG PUID=1000
ONBUILD ENV PUID=${PUID}
ONBUILD ARG PGID=1000
ONBUILD ENV PGID=${PGID}

ONBUILD RUN if [ "${PGID}" != "0" ] && [ "${PUID}" != "0" ]; then \
(grep -q ":${PGID}:" /etc/group && old_group=$(getent group ${PGID} | cut -d: -f1) && delgroup ${old_group} \
|| addgroup -g ${PGID} ${USER_CONTAINER}) \
&& (grep -q ":${PUID}:" /etc/passwd && old_user=$(getent passwd ${PUID} | cut -d: -f1) && deluser --remove-home ${old_user} \
|| adduser -h /home/${USER_CONTAINER} -G ${USER_CONTAINER} -u ${PUID} ${USER_CONTAINER} -D) \
fi

EXPOSE 80

STOPSIGNAL SIGTERM

CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
58 changes: 58 additions & 0 deletions slim/octane/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM alpine:3

LABEL org.opencontainers.image.source=https://github.com/digital-entropy/dokar-php
LABEL org.opencontainers.image.branch=8.3

ENV TERM=linux

ENV TZ=UTC

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apk update \
&& apk add --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing gosu \
&& apk add bash curl ca-certificates zip unzip git sqlite libcap libpng-dev \
php83 php83-dev php83-gd php83-curl php83-soap \
php83-sqlite3 php83-pgsql php83-mysqli \
php83-mbstring php83-xml php83-zip php83-bcmath \
php83-intl php83-ldap \
php83-pecl-igbinary php83-pecl-redis php83-pecl-swoole

RUN apk add composer \
&& composer global require --quiet --no-ansi laravel/envoy \
&& composer clear-cache --quiet \
&& ln -s /root/.composer/vendor/laravel/envoy/bin/envoy /usr/bin/envoy

RUN apk add nodejs npm \
&& npm install -g chokidar pnpm

RUN apk cache clean \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*

COPY runner.sh /runner.sh

# Add a non-root user to prevent files being created with root permissions on host machine.
ONBUILD ARG USER_CONTAINER=dokar
ONBUILD ENV USER_CONTAINER=${USER_CONTAINER}
ONBUILD ARG PUID=1000
ONBUILD ENV PUID=${PUID}
ONBUILD ARG PGID=1000
ONBUILD ENV PGID=${PGID}

# Convert to alpine
ONBUILD RUN if [ "${PGID}" != "0" ] && [ "${PUID}" != "0" ]; then \
(grep -q ":${PGID}:" /etc/group && old_group=$(getent group ${PGID} | cut -d: -f1) && delgroup ${old_group} \
|| addgroup -g ${PGID} ${USER_CONTAINER}) \
&& (grep -q ":${PUID}:" /etc/passwd && old_user=$(getent passwd ${PUID} | cut -d: -f1) && deluser --remove-home ${old_user} \
|| adduser -h /home/${USER_CONTAINER} -G ${USER_CONTAINER} -u ${PUID} ${USER_CONTAINER} -D) \
fi

EXPOSE 80

WORKDIR /var/www

ARG DOCKER_ENV=production
ENV DOCKER_ENV=${DOCKER_ENV}
ENV DOCKER_WORKERS=auto

CMD ["/runner.sh"]
29 changes: 29 additions & 0 deletions slim/octane/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -Eeo pipefail
set -o errexit # Used to exit upon error, avoiding cascading errors

IFS=$'\n\t'

cd /var/www

if [ -d vendor ]; then
echo "vendor ok!"
else
composer install
fi

echo "run on '$DOCKER_ENV' environment!"
echo "run with '$DOCKER_WORKERS' workers!"

if [ $DOCKER_ENV == "production" ]; then
php artisan octane:start --host=0.0.0.0 --port=80 --workers=$DOCKER_WORKERS --task-workers=$DOCKER_WORKERS
else
if [ -d node_modules ]; then
echo "node_modules ok!"
else
npm install
fi

php artisan octane:start --host=0.0.0.0 --watch --port=80 --workers=$DOCKER_WORKERS --task-workers=$DOCKER_WORKERS
fi
1 change: 1 addition & 0 deletions cli/Dockerfile → ubuntu/cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ubuntu:noble

LABEL org.opencontainers.image.source=https://github.com/digital-entropy/dokar-php
LABEL org.opencontainers.image.branch=8.3

ENV DEBIAN_FRONTEND=noninteractive

Expand Down
Loading

0 comments on commit 0aaac9e

Please sign in to comment.