feat(docker): update Docker configuration for Arvan Cloud registry and add API documentation generation

This commit is contained in:
2026-06-05 19:18:31 +03:30
parent 6eae917540
commit 0b99ab2119
7 changed files with 5785 additions and 9 deletions

View File

@@ -1,12 +1,13 @@
# syntax=docker/dockerfile:1.7 # syntax=docker.arvancloud.ir/docker/dockerfile:1.7
ARG DOCKER_REGISTRY=docker.arvancloud.ir
ARG PHP_VERSION=8.4 ARG PHP_VERSION=8.4
FROM composer:2 AS composer FROM ${DOCKER_REGISTRY}/node:24-alpine AS assets
FROM node:24-alpine AS assets
WORKDIR /app WORKDIR /app
RUN sed -i 's|https://dl-cdn.alpinelinux.org|https://mirror.arvancloud.ir/alpine|g' /etc/apk/repositories
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm ci RUN npm ci
@@ -15,14 +16,20 @@ COPY public ./public
COPY vite.config.js ./ COPY vite.config.js ./
RUN npm run build RUN npm run build
FROM php:${PHP_VERSION}-fpm-bookworm AS app ARG DOCKER_REGISTRY
ARG PHP_VERSION
FROM ${DOCKER_REGISTRY}/php:${PHP_VERSION}-fpm-bookworm AS app
WORKDIR /var/www/html WORKDIR /var/www/html
ENV COMPOSER_ALLOW_SUPERUSER=1 ENV COMPOSER_ALLOW_SUPERUSER=1
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/install-php-extensions COPY docker/php/install-php-extensions /usr/local/bin/install-php-extensions
COPY docker/apt/configure-arvan-mirror.sh /tmp/configure-arvan-mirror.sh
RUN apt-get update \ RUN chmod +x /tmp/configure-arvan-mirror.sh \
&& /tmp/configure-arvan-mirror.sh \
&& rm /tmp/configure-arvan-mirror.sh \
&& apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
curl \ curl \
default-mysql-client \ default-mysql-client \
@@ -38,12 +45,12 @@ RUN apt-get update \
xml \ xml \
xmlreader \ xmlreader \
zip \ zip \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& apt-get purge -y --auto-remove \ && apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY docker/php/php.ini /usr/local/etc/php/conf.d/99-production.ini COPY docker/php/php.ini /usr/local/etc/php/conf.d/99-production.ini
COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/99-opcache.ini COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/99-opcache.ini
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY composer.json composer.lock ./ COPY composer.json composer.lock ./
RUN composer install \ RUN composer install \
@@ -59,12 +66,14 @@ COPY --from=assets /app/public/build ./public/build
RUN composer dump-autoload --no-dev --optimize --no-scripts \ RUN composer dump-autoload --no-dev --optimize --no-scripts \
&& php artisan package:discover --ansi \ && php artisan package:discover --ansi \
&& APP_KEY=base64:dGVtcG9yYXJ5a2V5Zm9yZG9ja2VyYnVpbGRvbmx5= php artisan l5-swagger:generate --no-interaction \
&& mkdir -p \ && mkdir -p \
storage/app/public \ storage/app/public \
storage/framework/cache/data \ storage/framework/cache/data \
storage/framework/sessions \ storage/framework/sessions \
storage/framework/views \ storage/framework/views \
storage/logs \ storage/logs \
storage/api-docs \
bootstrap/cache \ bootstrap/cache \
&& rm -rf public/storage \ && rm -rf public/storage \
&& ln -s ../storage/app/public public/storage \ && ln -s ../storage/app/public public/storage \
@@ -78,7 +87,10 @@ EXPOSE 9000
ENTRYPOINT ["docker-entrypoint"] ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"] CMD ["php-fpm"]
FROM nginx:1.27-alpine AS nginx ARG DOCKER_REGISTRY
FROM ${DOCKER_REGISTRY}/nginx:1.27-alpine AS nginx
RUN sed -i 's|https://dl-cdn.alpinelinux.org|https://mirror.arvancloud.ir/alpine|g' /etc/apk/repositories
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=app /var/www/html/public /var/www/html/public COPY --from=app /var/www/html/public /var/www/html/public

View File

@@ -3,6 +3,8 @@ services:
build: build:
context: . context: .
target: app target: app
args:
DOCKER_REGISTRY: docker.arvancloud.ir
image: hoshpoint-backend-app:production image: hoshpoint-backend-app:production
restart: unless-stopped restart: unless-stopped
env_file: env_file:
@@ -25,6 +27,8 @@ services:
build: build:
context: . context: .
target: nginx target: nginx
args:
DOCKER_REGISTRY: docker.arvancloud.ir
image: hoshpoint-backend-nginx:production image: hoshpoint-backend-nginx:production
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env sh
set -eu
sources="/etc/apt/sources.list.d/debian.sources"
if [ ! -f "$sources" ]; then
exit 0
fi
sed -i \
-e 's|https\?://deb\.debian\.org/debian|http://mirror.arvancloud.ir/debian|g' \
-e 's|https\?://security\.debian\.org/debian-security|http://mirror.arvancloud.ir/debian|g' \
-e 's| bookworm-updates||g' \
"$sources"
sed -i '/mirror\.arvancloud\.ir\/debian-security/d' "$sources"

View File

@@ -0,0 +1,3 @@
{
"registry-mirrors": ["https://docker.arvancloud.ir"]
}

View File

@@ -7,6 +7,7 @@ mkdir -p \
storage/framework/sessions \ storage/framework/sessions \
storage/framework/views \ storage/framework/views \
storage/logs \ storage/logs \
storage/api-docs \
bootstrap/cache bootstrap/cache
if [ ! -L public/storage ]; then if [ ! -L public/storage ]; then
@@ -25,6 +26,10 @@ if [ -z "${APP_KEY:-}" ]; then
fi fi
if [ "${APP_ENV:-production}" = "production" ]; then if [ "${APP_ENV:-production}" = "production" ]; then
if php artisan list --raw 2>/dev/null | grep -q '^l5-swagger:generate'; then
php artisan l5-swagger:generate --no-interaction
fi
php artisan config:cache --no-interaction php artisan config:cache --no-interaction
php artisan event:cache --no-interaction php artisan event:cache --no-interaction
php artisan view:cache --no-interaction php artisan view:cache --no-interaction

5736
docker/php/install-php-extensions Executable file

File diff suppressed because it is too large Load Diff

View File