Compare commits

23 Commits

Author SHA1 Message Date
68c487857d Merge pull request #1 from kabaluyot/patch-1
docs: minor typo
2024-01-22 11:02:18 +01:00
Karl Anthony B. Baluyot
f1cc4805c9 docs: minor typo 2024-01-22 09:23:10 +08:00
10dd0a9320 delete manual flow 2023-05-02 13:46:17 +02:00
d83ec8b613 Update README.md 2022-11-01 22:37:01 +01:00
5dec27ab90 Update README.md 2022-11-01 22:35:03 +01:00
26f84f4fa7 enable arm and push 2022-11-01 22:10:13 +01:00
be1f93b028 enable cron job 2022-11-01 22:09:24 +01:00
9f7b912536 try with newlinw 2022-11-01 22:05:49 +01:00
bea16c129b try with comma 2022-11-01 22:01:36 +01:00
d0cbba385d try with explicit raw 2022-11-01 21:52:58 +01:00
2b84c86d45 separate with ; 2022-11-01 21:46:50 +01:00
06ca83bb58 try multiple tags 2022-11-01 21:39:50 +01:00
574c2b7b87 get latest version 2022-11-01 21:31:31 +01:00
22fbf4b955 also arm 2022-11-01 21:14:24 +01:00
403c9ad0c6 move to subdirectory 2022-11-01 21:07:58 +01:00
6af204ca70 use a min version 2022-11-01 21:03:21 +01:00
0324ed6d49 forgot to add output 2022-11-01 20:54:39 +01:00
6b5c91d122 formatting 2022-11-01 20:52:37 +01:00
9afda15154 set logging and serialize 2022-11-01 20:51:03 +01:00
461451257a forgot needs 2022-11-01 20:47:56 +01:00
7ebeb907d8 checkout 2022-11-01 20:46:05 +01:00
56f983a8e1 matrix build 2022-11-01 20:44:58 +01:00
b6f2e57965 trial matrix 2022-11-01 20:29:02 +01:00
8 changed files with 188 additions and 43 deletions

67
.github/workflows/cron.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
name: Matrix Cron Build
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * 1"
jobs:
tags:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.fetcher.outputs.matrix }}
defaults:
run:
working-directory: tags
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm i
- id: fetcher
run: node .
build:
runs-on: ubuntu-latest
needs: tags
strategy:
matrix: ${{fromJson(needs.tags.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Labels
id: meta
uses: docker/metadata-action@v4
with:
images: |
cupcakearmy/static
ghcr.io/${{ github.repository }}
tags: ${{ matrix.tags }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
platforms: linux/amd64,linux/arm64
build-args: NGINX=${{ matrix.version }}
tags: ${{ steps.meta.outputs.tags }}

View File

@@ -1,39 +0,0 @@
name: docker
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Labels
id: meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: cupcakearmy/static
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@@ -2,17 +2,17 @@
FROM alpine AS builder
ARG DEP_DEV="alpine-sdk zlib-dev pcre-dev openssl-dev gd-dev"
ARG NGINX_MODULES="--with-http_realip_module --with-threads --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_secure_link_module"
ARG NGINX=1.21.6
RUN apk add --no-cache ${DEP_DEV}
WORKDIR /build
ARG NGINX=1.21.6
RUN curl https://nginx.org/download/nginx-${NGINX}.tar.gz | tar xz
RUN mv nginx-${NGINX} nginx
RUN git clone --recursive https://github.com/google/ngx_brotli.git
WORKDIR /build/nginx
ARG NGINX_MODULES="--with-http_realip_module --with-threads --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_secure_link_module"
RUN ./configure ${NGINX_MODULES} --add-module=../ngx_brotli
RUN make
RUN make install

View File

@@ -4,9 +4,25 @@
![Docker Image Size (tag)](https://img.shields.io/docker/image-size/cupcakearmy/static/latest?style=flat-square)
![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/cupcakearmy/static/latest?style=flat-square)
This is a little docker image for histing static content efficiently.
This is a little docker image for hosting static content efficiently.
**Supports ETags & Brotli/GZip** compression out of the box.
Automatically builds the latest mainline and stable releases weekly.
## Features
- Brotli & GZip
- ETag
- No server tokens
## Tags
Tags follow the official nginx naming convention.
- `mainline`, same as `latest`
- `stable`
- Specific version
## Quickstart 🚀
```yaml

1
tags/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules

39
tags/index.js Normal file
View File

@@ -0,0 +1,39 @@
import { info, setOutput } from '@actions/core'
import semver from 'semver'
// Fetch the current versions from the download page
const URL = `https://nginx.org/en/download.html`
const html = await fetch(URL).then((r) => r.text())
// Find all the downloadable versions
const re = /"\/download\/nginx-(\d+\.){3}tar\.gz"/g
const matches = html.match(re)
// Clean up the matches to semver format
function clean(match) {
return match.replace(/"/g, '').replace('/download/nginx-', '').replace('.tar.gz', '')
}
const versions = matches.map(clean)
// Filter
// Get the two most up to date versions, mainline and stable
const filtered = versions.sort(semver.rcompare).slice(0, 2)
function convert(version, additional = []) {
return {
version,
// https://github.com/docker/metadata-action#typeraw
tags: [version, ...additional].map((t) => `type=raw,value=${t}`).join('\n'),
}
}
// Export as github action matrix
// https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations
const githubActionMatrix = {
include: [convert(filtered[0], ['latest', 'mainline']), convert(filtered[1], ['stable'])],
}
const serialised = JSON.stringify(githubActionMatrix)
info(`Found ${versions.length} versions`)
info(`Exporting as github action matrix: ${serialised}`)
setOutput('matrix', serialised)

8
tags/package.json Normal file
View File

@@ -0,0 +1,8 @@
{
"type": "module",
"main": "index.js",
"devDependencies": {
"@actions/core": "^1.10.0",
"semver": "^7.3.8"
}
}

53
tags/pnpm-lock.yaml generated Normal file
View File

@@ -0,0 +1,53 @@
lockfileVersion: 5.4
specifiers:
'@actions/core': ^1.10.0
semver: ^7.3.8
devDependencies:
'@actions/core': 1.10.0
semver: 7.3.8
packages:
/@actions/core/1.10.0:
resolution: {integrity: sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==}
dependencies:
'@actions/http-client': 2.0.1
uuid: 8.3.2
dev: true
/@actions/http-client/2.0.1:
resolution: {integrity: sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==}
dependencies:
tunnel: 0.0.6
dev: true
/lru-cache/6.0.0:
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
engines: {node: '>=10'}
dependencies:
yallist: 4.0.0
dev: true
/semver/7.3.8:
resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==}
engines: {node: '>=10'}
hasBin: true
dependencies:
lru-cache: 6.0.0
dev: true
/tunnel/0.0.6:
resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==}
engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'}
dev: true
/uuid/8.3.2:
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
hasBin: true
dev: true
/yallist/4.0.0:
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
dev: true