feat: 初始化 tbox-gateway 镜像构建配置及 Gitea 自动构建工作流
- 编写 Dockerfile 基础镜像及依赖扩展安装配置 - 配置 Gitea Actions 自动构建与推送镜像至容器仓库 (.gitea/workflows/docker-build.yml) - 增加 .gitignore 与使用说明文档
This commit is contained in:
commit
2292eb6e1e
4 files changed
+173
No files matched your search
@@ -0,0 +1,43 @@
|
|||||||
|
name: 构建并推送 Docker 镜像
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 检出源码
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 登录 Gitea 镜像仓库 (Container Registry)
|
||||||
|
run: |
|
||||||
|
# 提取 Gitea 主机名及端口 (去除协议头)
|
||||||
|
REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
|
||||||
|
echo "登录镜像仓库: ${REGISTRY_HOST}"
|
||||||
|
echo "${{ secrets.GITHUB_TOKEN }}" | docker login "${REGISTRY_HOST}" -u "${{ gitea.actor }}" --password-stdin
|
||||||
|
|
||||||
|
- name: 构建并推送 Docker 镜像
|
||||||
|
run: |
|
||||||
|
REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
|
||||||
|
# 镜像名称在 Docker 中必须全部小写
|
||||||
|
IMAGE_REPO=$(echo "${REGISTRY_HOST}/${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
# 判断当前是 Tag 还是分支提交
|
||||||
|
if [[ "${{ gitea.ref }}" =~ ^refs/tags/ ]]; then
|
||||||
|
VERSION_TAG="${{ gitea.ref_name }}"
|
||||||
|
docker build -t "${IMAGE_REPO}:${VERSION_TAG}" -t "${IMAGE_REPO}:latest" .
|
||||||
|
docker push "${IMAGE_REPO}:${VERSION_TAG}"
|
||||||
|
docker push "${IMAGE_REPO}:latest"
|
||||||
|
echo "已推送标签: ${IMAGE_REPO}:${VERSION_TAG} 和 ${IMAGE_REPO}:latest"
|
||||||
|
else
|
||||||
|
docker build -t "${IMAGE_REPO}:latest" .
|
||||||
|
docker push "${IMAGE_REPO}:latest"
|
||||||
|
echo "已推送标签: ${IMAGE_REPO}:latest"
|
||||||
|
fi
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
# 系统与编辑器文件
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.sublime-project
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# 临时与构建产物
|
||||||
|
tmp/
|
||||||
|
*.log
|
||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
# 2026-10-21 PHP2Shell 漏洞 (CVE-2026-109618 / CVE-2026-109619, CVSS 9.2) 紧急升级:
|
||||||
|
# 7.4 已 EOL 无官方修复版本, 升级至已修复的 8.3.36 (修复版本: 8.5.12 / 8.4.27 / 8.3.36 / 8.2.35)
|
||||||
|
FROM php:8.3.36-cli-alpine
|
||||||
|
# FROM php:8.1.24-cli
|
||||||
|
# FROM php:8.2.17-cli-alpine
|
||||||
|
# FROM php:8.3.4-cli-alpine
|
||||||
|
# FROM php:7.4.33-cli-alpine
|
||||||
|
|
||||||
|
|
||||||
|
# Container package : mirrors.163.com、mirrors.aliyun.com、mirrors.ustc.edu.cn
|
||||||
|
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories
|
||||||
|
# RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g" /etc/apk/repositories
|
||||||
|
|
||||||
|
RUN apk update
|
||||||
|
|
||||||
|
|
||||||
|
RUN apk add curl
|
||||||
|
RUN apk add git
|
||||||
|
RUN apk add supervisor
|
||||||
|
|
||||||
|
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
|
||||||
|
#COPY config/install-php-extensions /usr/local/bin/install-php-extensions
|
||||||
|
RUN chmod +x /usr/local/bin/install-php-extensions
|
||||||
|
|
||||||
|
RUN install-php-extensions bcmath
|
||||||
|
RUN install-php-extensions pdo
|
||||||
|
RUN install-php-extensions mysqli
|
||||||
|
RUN install-php-extensions pdo_mysql
|
||||||
|
RUN install-php-extensions redis
|
||||||
|
RUN install-php-extensions bz2
|
||||||
|
RUN install-php-extensions calendar
|
||||||
|
RUN install-php-extensions opcache
|
||||||
|
RUN install-php-extensions pcntl
|
||||||
|
RUN install-php-extensions sockets
|
||||||
|
RUN install-php-extensions event
|
||||||
|
RUN install-php-extensions pdo_pgsql
|
||||||
|
RUN install-php-extensions pgsql
|
||||||
|
RUN install-php-extensions zip
|
||||||
|
RUN install-php-extensions gd
|
||||||
|
RUN install-php-extensions gmp
|
||||||
|
#RUN install-php-extensions xdebug
|
||||||
|
|
||||||
|
RUN php -m
|
||||||
|
|
||||||
|
# Add Composer
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
|
||||||
|
|
||||||
|
# Configure PHP
|
||||||
|
#COPY config/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini
|
||||||
|
|
||||||
|
# Make sure files/folders needed by the processes are accessable when they run under the nobody user
|
||||||
|
RUN chown -R nobody.nobody /run
|
||||||
|
|
||||||
|
# Setup document root
|
||||||
|
RUN mkdir -p /app
|
||||||
|
|
||||||
|
# Make the document root a volume
|
||||||
|
VOLUME /app
|
||||||
|
|
||||||
|
#echo " > /usr/local/etc/php/conf.d/phalcon.ini
|
||||||
|
# Switch to use a non-root user from here on
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Add application
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Expose the port nginx is reachable on
|
||||||
|
EXPOSE 8787
|
||||||
|
|
||||||
|
#COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
|
# Let supervisord start nginx & php
|
||||||
|
#CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||||
|
CMD ["php", "/app/start.php","start"]
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# TBox-Gateway Docker Image
|
||||||
|
|
||||||
|
本项目包含 `tbox-gateway` 基础运行环境的 Docker 镜像定义,并配置了 Gitea Actions 自动构建与发布流程。
|
||||||
|
|
||||||
|
## 镜像拉取与使用
|
||||||
|
|
||||||
|
推送代码到分支后,Gitea 会自动触发构建并推送到 Gitea 的 Container Registry。
|
||||||
|
|
||||||
|
### 1. 登录 Gitea 镜像仓库
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker login <Gitea主机或IP:端口> -u <用户名> -p <密码或访问令牌>
|
||||||
|
```
|
||||||
|
*例如:`docker login 192.168.101.230:3000`*
|
||||||
|
|
||||||
|
### 2. 拉取镜像
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull <Gitea主机或IP:端口>/<组织或用户名>/<仓库名>:latest
|
||||||
|
```
|
||||||
|
*例如:*
|
||||||
|
```bash
|
||||||
|
docker pull 192.168.101.230:3000/mygroup/tbox-gateway:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
> **注意(非 HTTPS/自签名证书):**
|
||||||
|
> 如果内网 Gitea 使用的是 HTTP 协议,请在客户端 `/etc/docker/daemon.json`(或 Docker Desktop 设置)中加入不安全仓库配置:
|
||||||
|
> ```json
|
||||||
|
> {
|
||||||
|
> "insecure-registries": ["192.168.101.230:3000"]
|
||||||
|
> }
|
||||||
|
> ```
|
||||||
|
> 然后重启 Docker 服务。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 自动化构建配置
|
||||||
|
|
||||||
|
CI 流程已配置在 [`.gitea/workflows/docker-build.yml`](.gitea/workflows/docker-build.yml):
|
||||||
|
- 当代码推送至 `master` 或 `main` 分支时,自动触发构建并推送 `:latest` 镜像。
|
||||||
|
- 当推送版本标签(如 `v1.0.0`)时,自动构建并同时推送对应标签及 `:latest`。
|
||||||
|
- 构建所需环境需在 Gitea 中开启 Actions 并注册 `act_runner`(具备 Docker daemon 权限)。
|
||||||
Reference in new issue
Block a user