Skip to content
Jetsung Chan edited this page Jun 30, 2022 · 15 revisions

Document

Build

使用 main 版本的代码构建和编译:

git clone https://github.com/skiy/docker-nginx-php.git
cd nginx-php
  • 方式一:直接编译
docker build --build-arg PHP_VERSION="7.3.33" \
  --build-arg NGINX_VERSION="1.20.0" \
  -t nginx-php:7.3 \
  -f ./Dockerfile .
  • 方式二:一键编译脚本 build.sh
    文件 .env
# PHP 和 NGINX 版本号
# 7.3.330 => PHP:7.3.33
# Docker tag: 7.3.330 则为 nginx-php:7.3.330 / nginx-php:7.3
IMAGE_VERSION=7.3.330
NGINX_VERSION=1.21.5

# 若为中国镜像需要设置,若使用国外 VPS 编译,可以删除以下两行
GH_MIRROR_URL=https://ghproxy.com/
CN_MIRROR=1

# 是否推送到 (Docker Registry)
D_PUSH=false
# 编译构架 linux/amd64,linux/arm64
D_PLATFORM="linux/amd64"

然后执行 ./build.sh xxx env 0 来编译

参数说明:
xxx 为你的 Docker Registry (默认: hub.docker.com) 用户名
env 为是否使用 .env
0 为不使用 buildx 构建。多构架时需要使用此扩展

注意:

1、若是需要推送,则需要先手动登录到对应的 Docker Registry,比如官方的 https://docker.io

docker login -u xxx -p https://docker.io

2、若需要增加自定义扩展,需要按照相应的执行代码在启动镜像时挂载到容器中。可参考 redis.sh 中的代码复制到文件 extension.sh 中,再使用参数 -v 挂载过去。多个扩展,都可以添加到此文件中。

Clone this wiki locally