Compare commits
10 Commits
31a3dbdf30
...
977877683a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
977877683a | ||
|
|
69b97bde94 | ||
|
|
9a48bbcb9a | ||
|
|
c1ec354de1 | ||
|
|
f9939d3e68 | ||
|
|
5d0f53ce49 | ||
|
|
74a928646f | ||
|
|
0742760954 | ||
|
|
4ae504c26a | ||
|
|
f3d29e77ab |
@@ -5,12 +5,12 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- "v*"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: git.home.db123.ir
|
REGISTRY: git.home.db123.ir
|
||||||
NAMESPACE: db1234719
|
NAMESPACE: db1234719
|
||||||
IMAGE_NAME: nginx-alpine
|
IMAGE_NAME: php-alpine
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 1
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Determine version
|
- name: Determine version
|
||||||
@@ -45,6 +45,7 @@ jobs:
|
|||||||
password: ${{ secrets.CICD_PASSWORD }}
|
password: ${{ secrets.CICD_PASSWORD }}
|
||||||
|
|
||||||
- name: Build & push Docker image
|
- name: Build & push Docker image
|
||||||
|
id: build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -56,3 +57,16 @@ jobs:
|
|||||||
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}
|
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:cache
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:cache
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:cache,mode=max
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:cache,mode=max
|
||||||
|
|
||||||
|
- name: Notify build result
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
if [ "${{ steps.build.outcome }}" = "success" ]; then
|
||||||
|
curl -s -S -u "server:VKbpgw75KB0biM" \
|
||||||
|
-d "build & push succeeded ✅" \
|
||||||
|
https://ntfy.home.db123.ir/build
|
||||||
|
else
|
||||||
|
curl -s -S -u "server:VKbpgw75KB0biM" \
|
||||||
|
-d "build & push FAILED ❌" \
|
||||||
|
https://ntfy.home.db123.ir/build
|
||||||
|
fi
|
||||||
|
|||||||
31
Dockerfile
31
Dockerfile
@@ -4,13 +4,13 @@ FROM alpine:3.22 AS builder
|
|||||||
ENV PHP_VERSION=8.5.0
|
ENV PHP_VERSION=8.5.0
|
||||||
|
|
||||||
# Build dependencies
|
# Build dependencies
|
||||||
RUN apk add \
|
RUN apk add --no-cache \
|
||||||
build-base autoconf bison re2c \
|
build-base autoconf bison re2c \
|
||||||
|
postgresql-dev \
|
||||||
curl tar \
|
curl tar \
|
||||||
libxml2-dev openssl-dev sqlite-dev zlib-dev pcre2-dev libzip-dev oniguruma-dev \
|
libxml2-dev openssl-dev sqlite-dev zlib-dev pcre2-dev libzip-dev oniguruma-dev \
|
||||||
postgresql-dev \
|
|
||||||
freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \
|
freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \
|
||||||
imap-dev krb5-dev
|
curl-dev
|
||||||
|
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
|
|
||||||
@@ -39,13 +39,10 @@ RUN ./configure \
|
|||||||
--with-sqlite3 \
|
--with-sqlite3 \
|
||||||
--with-pdo-sqlite \
|
--with-pdo-sqlite \
|
||||||
--with-pdo-pgsql \
|
--with-pdo-pgsql \
|
||||||
--with-pgsql \
|
|
||||||
--with-gd \
|
--with-gd \
|
||||||
--with-jpeg \
|
--with-jpeg \
|
||||||
--with-webp \
|
--with-webp \
|
||||||
--with-freetype \
|
--with-freetype
|
||||||
--with-imap \
|
|
||||||
--with-imap-ssl
|
|
||||||
|
|
||||||
RUN make -j$(nproc) && make install
|
RUN make -j$(nproc) && make install
|
||||||
|
|
||||||
@@ -54,16 +51,23 @@ RUN cp php.ini-production /usr/local/php/php.ini
|
|||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
RUN rm -rf /tmp/* /var/cache/apk/*
|
RUN rm -rf /tmp/* /var/cache/apk/*
|
||||||
|
RUN rm -rf /usr/local/php/lib/php/build
|
||||||
|
RUN rm -rf /usr/local/php/include
|
||||||
|
RUN rm -rf /usr/local/php/php/man
|
||||||
|
|
||||||
|
# Strip
|
||||||
|
RUN strip --strip-all /usr/local/php/bin/php || true
|
||||||
|
RUN strip --strip-all /usr/local/php/sbin/php-fpm || true
|
||||||
|
RUN find /usr/local/php -name "*.so" -exec strip --strip-unneeded {} \; || true
|
||||||
|
|
||||||
# --- Stage 2: Runtime ---
|
# --- Stage 2: Runtime ---
|
||||||
FROM alpine:3.22
|
FROM alpine:3.22
|
||||||
|
|
||||||
# Runtime libraries only
|
# Runtime libraries only
|
||||||
RUN apk add \
|
RUN apk add --no-cache \
|
||||||
libxml2 openssl sqlite-libs zlib libzip pcre2 oniguruma \
|
libxml2 openssl zlib libzip pcre2 oniguruma \
|
||||||
postgresql-libs \
|
|
||||||
freetype libpng libjpeg-turbo libwebp \
|
freetype libpng libjpeg-turbo libwebp \
|
||||||
imap krb5-libs
|
postgresql-libs
|
||||||
|
|
||||||
RUN addgroup -S php && adduser -S -D -H -G php php
|
RUN addgroup -S php && adduser -S -D -H -G php php
|
||||||
RUN mkdir -p /usr/local/php/conf.d /var/run/php
|
RUN mkdir -p /usr/local/php/conf.d /var/run/php
|
||||||
@@ -71,6 +75,11 @@ RUN mkdir -p /usr/local/php/conf.d /var/run/php
|
|||||||
# Copy compiled PHP
|
# Copy compiled PHP
|
||||||
COPY --from=builder /usr/local/php /usr/local/php
|
COPY --from=builder /usr/local/php /usr/local/php
|
||||||
|
|
||||||
|
# Copy hardened configs on top
|
||||||
|
COPY php-fpm.conf /usr/local/php/php-fpm.conf
|
||||||
|
COPY php-fpm.d/www.conf /usr/local/php/php-fpm.d/www.conf
|
||||||
|
COPY conf.d/security.ini /usr/local/php/conf.d/security.ini
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
USER php
|
USER php
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ opcache.max_accelerated_files = 12000
|
|||||||
opcache.save_comments = 1
|
opcache.save_comments = 1
|
||||||
opcache.jit = 0
|
opcache.jit = 0
|
||||||
|
|
||||||
; timezone (override manually)
|
; timezone
|
||||||
date.timezone = UTC
|
date.timezone = Asia/Tehran
|
||||||
|
|
||||||
; forbid URL file wrappers unless needed
|
; forbid URL file wrappers unless needed
|
||||||
allow_url_fopen = Off
|
allow_url_fopen = Off
|
||||||
|
|||||||
Reference in New Issue
Block a user