test_laravel/dockerfile

29 lines
929 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FROM php:7.3-fpm
# 替换为清华大学镜像源Debian 10 Buster
RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \
&& sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
# 安装系统依赖和扩展
RUN apt-get update && apt-get install -y \
libzip-dev \
unzip \
&& docker-php-ext-install pdo_mysql zip
# 安装 Composer
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin \
--filename=composer
# 创建非 root 用户(推荐与宿主机用户 UID/GID 一致)
ARG USER_ID=1003 # 宿主机 deploy-user 的 UID
ARG GROUP_ID=1003 # 宿主机 deploy-user 的 GID
RUN groupadd -g ${GROUP_ID} appuser \
&& useradd -u ${USER_ID} -g appuser -m -d /home/appuser -s /bin/bash appuser
# 设置工作目录权限
RUN chown -R appuser:appuser /var/www/html
# 切换到非 root 用户
USER appuser