mirror of
https://github.com/certd/certd.git
synced 2026-07-17 03:17:34 +08:00
ci(ci): add alpine image build workflow and refactor dockerfile
重构了packages/ui的Dockerfile,支持通过build-arg指定基础镜像类型,新增了多架构的alpine镜像构建任务,适配不同场景的镜像使用需求
This commit is contained in:
@@ -94,6 +94,22 @@ jobs:
|
|||||||
greper/certd:${{steps.get_certd_version.outputs.result}}
|
greper/certd:${{steps.get_certd_version.outputs.result}}
|
||||||
ghcr.io/${{ github.repository }}:latest
|
ghcr.io/${{ github.repository }}:latest
|
||||||
ghcr.io/${{ github.repository }}:${{steps.get_certd_version.outputs.result}}
|
ghcr.io/${{ github.repository }}:${{steps.get_certd_version.outputs.result}}
|
||||||
|
- name: Build alpine
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
context: ./packages/ui/
|
||||||
|
build-args: |
|
||||||
|
base_type=alpine
|
||||||
|
tags: |
|
||||||
|
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:alpine
|
||||||
|
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${{steps.get_certd_version.outputs.result}}-alpine
|
||||||
|
greper/certd:alpine
|
||||||
|
greper/certd:${{steps.get_certd_version.outputs.result}}-alpine
|
||||||
|
ghcr.io/${{ github.repository }}:alpine
|
||||||
|
ghcr.io/${{ github.repository }}:${{steps.get_certd_version.outputs.result}}-alpine
|
||||||
|
|
||||||
- name: Build armv7
|
- name: Build armv7
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
|
|||||||
+28
-13
@@ -1,9 +1,15 @@
|
|||||||
# 根据目标平台选择基础镜像:amd64/arm64 用 trixie-slim,arm/v7 没有 trixie-slim 发布,回退到 alpine
|
ARG base_type=slim
|
||||||
FROM --platform=linux/amd64 node:22-trixie-slim AS base-amd64
|
|
||||||
FROM --platform=linux/arm64 node:22-trixie-slim AS base-arm64
|
|
||||||
FROM --platform=linux/arm/v7 node:22-alpine AS base-arm-v7
|
|
||||||
|
|
||||||
FROM base-${TARGETARCH}${TARGETVARIANT:+-}${TARGETVARIANT} AS builder
|
# 根据 base_type 参数选择基础镜像系列
|
||||||
|
FROM --platform=linux/amd64 node:22-alpine AS base-amd64-alpine
|
||||||
|
FROM --platform=linux/arm64 node:22-alpine AS base-arm64-alpine
|
||||||
|
FROM --platform=linux/arm/v7 node:22-alpine AS base-arm-v7-alpine
|
||||||
|
|
||||||
|
FROM --platform=linux/amd64 node:22-trixie-slim AS base-amd64-slim
|
||||||
|
FROM --platform=linux/arm64 node:22-trixie-slim AS base-arm64-slim
|
||||||
|
FROM --platform=linux/arm/v7 node:22-alpine AS base-arm-v7-slim
|
||||||
|
|
||||||
|
FROM base-${TARGETARCH}${TARGETVARIANT:+-}${TARGETVARIANT}-${base_type} AS builder
|
||||||
|
|
||||||
WORKDIR /workspace/
|
WORKDIR /workspace/
|
||||||
COPY . /workspace/
|
COPY . /workspace/
|
||||||
@@ -15,12 +21,17 @@ RUN cp /workspace/certd-client/dist/* /workspace/certd-server/public/ -rf
|
|||||||
RUN cd /workspace/certd-server && pnpm install --production && npm run build-on-docker
|
RUN cd /workspace/certd-server && pnpm install --production && npm run build-on-docker
|
||||||
|
|
||||||
|
|
||||||
FROM base-${TARGETARCH}${TARGETVARIANT:+-}${TARGETVARIANT}
|
ARG base_type=slim
|
||||||
|
|
||||||
|
FROM base-${TARGETARCH}${TARGETVARIANT:+-}${TARGETVARIANT}-${base_type}
|
||||||
EXPOSE 7001
|
EXPOSE 7001
|
||||||
EXPOSE 7002
|
EXPOSE 7002
|
||||||
|
|
||||||
|
ARG base_type=slim
|
||||||
|
|
||||||
# 根据基础镜像发行版选择包管理器
|
# 根据基础镜像发行版选择包管理器
|
||||||
# trixie-slim -> apt-get, alpine -> apk
|
# trixie-slim -> apt-get, alpine -> apk
|
||||||
|
# base_type=alpine 时不安装 openjdk
|
||||||
RUN if [ -f /etc/debian_version ]; then \
|
RUN if [ -f /etc/debian_version ]; then \
|
||||||
apt-get update \
|
apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
@@ -32,16 +43,20 @@ RUN if [ -f /etc/debian_version ]; then \
|
|||||||
iputils-ping \
|
iputils-ping \
|
||||||
dnsutils \
|
dnsutils \
|
||||||
iproute2 \
|
iproute2 \
|
||||||
&& wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | tee /usr/share/keyrings/adoptium.gpg > /dev/null \
|
&& if [ "$base_type" != "alpine" ]; then \
|
||||||
&& echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb bookworm main" | tee /etc/apt/sources.list.d/adoptium.list \
|
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | tee /usr/share/keyrings/adoptium.gpg > /dev/null \
|
||||||
&& apt-get update \
|
&& echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb bookworm main" | tee /etc/apt/sources.list.d/adoptium.list \
|
||||||
&& apt-get install -y --no-install-recommends temurin-8-jre \
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends temurin-8-jre; \
|
||||||
|
fi \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*; \
|
&& rm -rf /var/lib/apt/lists/*; \
|
||||||
elif [ -f /etc/alpine-release ]; then \
|
elif [ -f /etc/alpine-release ]; then \
|
||||||
apk add --no-cache \
|
if [ "$base_type" = "alpine" ]; then \
|
||||||
openssl \
|
apk add --no-cache openssl; \
|
||||||
openjdk8-jre; \
|
else \
|
||||||
|
apk add --no-cache openssl openjdk8-jre; \
|
||||||
|
fi; \
|
||||||
else \
|
else \
|
||||||
echo "Unsupported base image"; exit 1; \
|
echo "Unsupported base image"; exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user