forked from github-mirrorer/quake-kube
Add push-image action, small fixes (#21)
* Add push-image action * Update example
This commit is contained in:
77
.github/workflows/push-image.yaml
vendored
Normal file
77
.github/workflows/push-image.yaml
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
name: Push Image
|
||||
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
jobs:
|
||||
push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Prepare
|
||||
id: prep
|
||||
run: |
|
||||
DOCKER_IMAGE=${GITHUB_REPOSITORY}
|
||||
VERSION=noop
|
||||
if [ "${{ github.event_name }}" = "schedule" ]; then
|
||||
VERSION=nightly
|
||||
elif [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
||||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
|
||||
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
|
||||
VERSION=edge
|
||||
fi
|
||||
elif [[ $GITHUB_REF == refs/pull/* ]]; then
|
||||
VERSION=pr-${{ github.event.number }}
|
||||
fi
|
||||
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
||||
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
MINOR=${VERSION%.*}
|
||||
MAJOR=${MINOR%.*}
|
||||
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
|
||||
elif [ "${{ github.event_name }}" = "push" ]; then
|
||||
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
|
||||
fi
|
||||
echo ::set-output name=version::${VERSION}
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- 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:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.prep.outputs.tags }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ q3: gen
|
||||
gen: ## Generate and embed templates
|
||||
@go run tools/genstatic.go public public
|
||||
|
||||
VERSION ?= v1.0.5
|
||||
VERSION ?= latest
|
||||
IMAGE ?= docker.io/criticalstack/quake:$(VERSION)
|
||||
|
||||
.PHONY: build
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||

|
||||
|
||||
# QuakeKube
|
||||
|
||||
QuakeKube is a Kubernetes-ified version of [QuakeJS](https://github.com/inolen/quakejs) that runs a dedicated [Quake 3](https://en.wikipedia.org/wiki/Quake_III_Arena) server in a Kubernetes Deployment, and then allow clients to connect via QuakeJS in the browser.
|
||||
|
||||
16
example.yaml
16
example.yaml
@ -1,16 +1,16 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: quakejs
|
||||
name: quake
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
run: quakejs
|
||||
run: quake
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
run: quakejs
|
||||
run: quake
|
||||
annotations:
|
||||
prometheus.io/scrape: 'true'
|
||||
prometheus.io/port: '8080'
|
||||
@ -20,9 +20,9 @@ spec:
|
||||
- q3
|
||||
- server
|
||||
- --config=/config/config.yaml
|
||||
- --content-server=http://localhost:9090
|
||||
- --content-server=http://127.0.0.1:9090
|
||||
- --agree-eula
|
||||
image: docker.io/criticalstack/quake:v1.0.5
|
||||
image: docker.io/criticalstack/quake:latest
|
||||
name: server
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
@ -40,7 +40,7 @@ spec:
|
||||
- q3
|
||||
- content
|
||||
- --seed-content-url=http://content.quakejs.com
|
||||
image: docker.io/criticalstack/quake:v1.0.5
|
||||
image: docker.io/criticalstack/quake:latest
|
||||
name: content-server
|
||||
ports:
|
||||
- containerPort: 9090
|
||||
@ -57,11 +57,11 @@ spec:
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: quakejs
|
||||
name: quake
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
run: quakejs
|
||||
run: quake
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
@ -55,10 +56,7 @@ func NewRouter(cfg *Config) (*echo.Echo, error) {
|
||||
return c.JSONPretty(http.StatusOK, files, " ")
|
||||
})
|
||||
e.GET("/assets/*", func(c echo.Context) error {
|
||||
path := filepath.Join(cfg.AssetsDir, c.Param("*"))
|
||||
d, f := filepath.Split(path)
|
||||
f = f[strings.Index(f, "-")+1:]
|
||||
path = filepath.Join(d, f)
|
||||
path := filepath.Join(cfg.AssetsDir, trimAssetName(c.Param("*")))
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
return c.String(http.StatusNotFound, "file not found")
|
||||
}
|
||||
@ -131,3 +129,11 @@ func NewRouter(cfg *Config) (*echo.Echo, error) {
|
||||
})
|
||||
return e, nil
|
||||
}
|
||||
|
||||
var assetPattern = regexp.MustCompile(`(\d+-)`)
|
||||
|
||||
// trimAssetName returns a path string that has been prefixed with a crc32
|
||||
// checksum.
|
||||
func trimAssetName(s string) string {
|
||||
return assetPattern.ReplaceAllLiteralString(s, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user