86 lines
2.9 KiB
Docker
86 lines
2.9 KiB
Docker
FROM openeuler/openeuler:24.03 AS dev
|
|
|
|
## 设置工作目录
|
|
#WORKDIR /app
|
|
|
|
# 更新系统和安装软件包
|
|
RUN dnf update -y && \
|
|
dnf install -y git php-cli php-bcmath php-mbstring php-pdo php-pecl-zip php-opcache php-sodium php-intl php-pear php-devel c-ares-devel libcurl-devel openssl-devel brotli brotli-devel net-tools && \
|
|
dnf clean all && \
|
|
rm -rf /var/cache/dnf/*
|
|
|
|
# 配置 PHP 扩展
|
|
RUN echo "extension=/usr/lib64/php/modules/zstd.so" > /etc/php.d/20-zstd.ini && \
|
|
echo "extension=/usr/lib64/php/modules/swoole.so" > /etc/php.d/50-swoole.ini
|
|
|
|
# 安装 PECL 扩展
|
|
RUN pecl channel-update https://pecl.php.net/channel.xml && \
|
|
pecl install zstd && \
|
|
pecl install swoole
|
|
|
|
# 安装 Node.js 和 Composer
|
|
RUN architecture=$(uname -m) && \
|
|
if [ "$architecture" = "aarch64" ]; then \
|
|
echo "Current architecture is ARM64" && \
|
|
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/v20.16.0/node-v20.16.0-linux-arm64.tar.xz | tar -xJ --strip-components=1 -C /usr/local; \
|
|
elif [ "$architecture" = "x86_64" ]; then \
|
|
echo "Current architecture is x86_64" && \
|
|
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/v20.16.0/node-v20.16.0-linux-x64.tar.xz | tar -xJ --strip-components=1 -C /usr/local; \
|
|
else \
|
|
echo "platform [$architecture] not supported" && exit 1; \
|
|
fi && \
|
|
curl -fsSL https://getcomposer.org/download/latest-stable/composer.phar -o /usr/local/bin/composer && \
|
|
chmod +x /usr/local/bin/composer && \
|
|
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
|
|
|
|
# 配置 PHP 内存限制
|
|
RUN sed -i 's/memory_limit\s*=.*/memory_limit = 1024M/g' /etc/php.ini
|
|
|
|
# 配置 npm 和 yarn 源
|
|
RUN npm config set registry https://registry.npmmirror.com && \
|
|
npm install -g yarn && \
|
|
yarn config set registry https://registry.npmmirror.com
|
|
|
|
FROM openeuler/openeuler:24.03 AS runtime
|
|
RUN dnf update -y \
|
|
&& dnf install php-cli php-bcmath php-mbstring php-pdo php-pecl-zip php-posix php-sodium php-xml php-intl php-opcache c-ares libcurl openssl brotli net-tools -y \
|
|
&& dnf clean all && rm -rf /var/cache/dnf/*
|
|
|
|
RUN mkdir -p /usr/lib64/php/modules/
|
|
|
|
COPY --from=dev /usr/lib64/php/modules/zstd.so /usr/lib64/php/modules/zstd.so
|
|
COPY --from=dev /usr/lib64/php/modules/swoole.so /usr/lib64/php/modules/swoole.so
|
|
|
|
RUN echo "extension=/usr/lib64/php/modules/zstd.so" > /etc/php.d/20-zstd.ini \
|
|
&& echo "extension=/usr/lib64/php/modules/swoole.so" > /etc/php.d/50-swoole.ini
|
|
|
|
RUN sed -i 's/memory_limit\s*=.*/memory_limit = 4096M/g' /etc/php.ini
|
|
|
|
WORKDIR /app
|
|
|
|
FROM dev AS build
|
|
|
|
COPY . /app
|
|
|
|
WORKDIR /app
|
|
|
|
RUN composer install --no-dev --no-suggest --optimize-autoloader
|
|
|
|
RUN yarn \
|
|
&& rm -rf node_modules \
|
|
&& cp .env.example .env \
|
|
&& php artisan key:generate
|
|
|
|
FROM runtime AS release
|
|
|
|
COPY --from=build /app /app
|
|
|
|
RUN chmod +x /app/entrypoint.sh \
|
|
&& chmod +x /app/artisan
|
|
|
|
# 暴露端口
|
|
EXPOSE 8000
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|