test exposing ssh keys during docker build

This commit is contained in:
2025-08-14 20:54:11 +08:00
parent aaefd685c0
commit 70e2185ed5
2 changed files with 38 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ jobs:
username: woggioni username: woggioni
password: ${{ secrets.PUBLISHER_TOKEN }} password: ${{ secrets.PUBLISHER_TOKEN }}
- -
name: Build and push nginx images name: Build and push nginx vanilla images
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: "{{defaultContext}}:nginx" context: "{{defaultContext}}:nginx"
@@ -34,12 +34,35 @@ jobs:
linux/arm64 linux/arm64
push: true push: true
pull: true pull: true
ssh: default=/home/luser/.ssh/id_ed25519
tags: | tags: |
"gitea.woggioni.net/woggioni/nginx:latest" "gitea.woggioni.net/woggioni/nginx:latest"
"gitea.woggioni.net/woggioni/nginx:v1.29.1" "gitea.woggioni.net/woggioni/nginx:v1.29.1"
secrets: | secrets: |
GIT_AUTH_TOKEN.github.com=${{ secrets.GH_ACCESS_TOKEN }} GIT_AUTH_TOKEN.github.com=${{ secrets.GH_ACCESS_TOKEN }}
build-args: "NGINX_VERSION=1.29.1" build-args: |
cache-from: type=registry,ref=gitea.woggioni.net/woggioni/nginx:buildx NGINX_VERSION=1.29.1
cache-to: type=registry,mode=max,compression=zstd,image-manifest=true,oci-mediatypes=true,ref=gitea.woggioni.net/woggioni/nginx:buildx NGINX_BRANCH=vanilla
cache-from: type=registry,ref=gitea.woggioni.net/woggioni/nginx:buildx-vanilla
cache-to: type=registry,mode=max,compression=zstd,image-manifest=true,oci-mediatypes=true,ref=gitea.woggioni.net/woggioni/nginx:buildx-woggioni
-
name: Build and push nginx custom images
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:nginx"
platforms: |
linux/amd64
linux/arm64
push: true
pull: true
ssh: default=/home/luser/.ssh/id_ed25519
tags: |
"gitea.woggioni.net/woggioni/nginx:woggioni"
"gitea.woggioni.net/woggioni/nginx:v1.29.1-woggioni"
secrets: |
GIT_AUTH_TOKEN.github.com=${{ secrets.GH_ACCESS_TOKEN }}
build-args: |
NGINX_VERSION=1.29.1
NGINX_BRANCH=woggioni
cache-from: type=registry,ref=gitea.woggioni.net/woggioni/nginx:buildx-woggioni
cache-to: type=registry,mode=max,compression=zstd,image-manifest=true,oci-mediatypes=true,ref=gitea.woggioni.net/woggioni/nginx:buildx-woggioni

View File

@@ -1,8 +1,8 @@
FROM alpine:latest AS base FROM alpine:latest AS base
FROM alpine:latest AS build FROM alpine:latest AS build_stage_1
ARG NGINX_VERSION LIBRESSL_VERSION=4.1.0 ARG NGINX_VERSION LIBRESSL_VERSION=4.1.0 NGINX_BRANCH=vanilla
ENV NGINX_VERSION=${NGINX_VERSION} ENV NGINX_VERSION=${NGINX_VERSION}
RUN --mount=type=cache,target=/var/cache/apk apk update RUN --mount=type=cache,target=/var/cache/apk apk update
RUN --mount=type=cache,target=/var/cache/apk apk add \ RUN --mount=type=cache,target=/var/cache/apk apk add \
@@ -42,6 +42,8 @@ USER luser
WORKDIR /home/luser WORKDIR /home/luser
#RUN git clone --depth 1 --branch v4.0.0 https://github.com/libressl/portable.git libressl #RUN git clone --depth 1 --branch v4.0.0 https://github.com/libressl/portable.git libressl
#RUN git clone --depth 1 --branch v4.0.0 https://github.com/libressl/portable.git libressl
#ADD --chown=luser:luser git@github.com:libressl/portable.git#v${LIBRESSL_VERSION} libressl
ADD --chown=luser:luser https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz libressl.tgz ADD --chown=luser:luser https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz libressl.tgz
RUN tar -xzf libressl.tgz && mv libressl-${LIBRESSL_VERSION} libressl && rm libressl.tgz RUN tar -xzf libressl.tgz && mv libressl-${LIBRESSL_VERSION} libressl && rm libressl.tgz
RUN mkdir -p libressl/build RUN mkdir -p libressl/build
@@ -55,7 +57,13 @@ RUN cmake -G Ninja -B libressl/build -S libressl \
-DBUILD_SHARED_LIBS=OFF -DBUILD_SHARED_LIBS=OFF
RUN cmake --build libressl/build RUN cmake --build libressl/build
FROM build_stage_1 AS build_stage_2_vanilla
ADD --chown=luser:luser https://github.com/nginx/nginx.git#release-${NGINX_VERSION} /nginx ADD --chown=luser:luser https://github.com/nginx/nginx.git#release-${NGINX_VERSION} /nginx
FROM build_stage_1 AS build_stage_2_woggioni
ADD --chown=luser:luser git@github.com:woggioni/nginx.git#release-${NGINX_VERSION} /nginx
FROM build_stage_2_${NGINX_BRANCH} AS build
ADD --chown=luser:luser https://github.com/openresty/headers-more-nginx-module.git /ngx_headers_more ADD --chown=luser:luser https://github.com/openresty/headers-more-nginx-module.git /ngx_headers_more
ADD --chown=luser:luser https://github.com/google/ngx_brotli.git /ngx_brotli ADD --chown=luser:luser https://github.com/google/ngx_brotli.git /ngx_brotli
USER root USER root