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
|
gen: ## Generate and embed templates
|
||||||
@go run tools/genstatic.go public public
|
@go run tools/genstatic.go public public
|
||||||
|
|
||||||
VERSION ?= v1.0.5
|
VERSION ?= latest
|
||||||
IMAGE ?= docker.io/criticalstack/quake:$(VERSION)
|
IMAGE ?= docker.io/criticalstack/quake:$(VERSION)
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|

|
||||||
|
|
||||||
# QuakeKube
|
# 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.
|
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
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: quakejs
|
name: quake
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
run: quakejs
|
run: quake
|
||||||
replicas: 1
|
replicas: 1
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
run: quakejs
|
run: quake
|
||||||
annotations:
|
annotations:
|
||||||
prometheus.io/scrape: 'true'
|
prometheus.io/scrape: 'true'
|
||||||
prometheus.io/port: '8080'
|
prometheus.io/port: '8080'
|
||||||
@ -20,9 +20,9 @@ spec:
|
|||||||
- q3
|
- q3
|
||||||
- server
|
- server
|
||||||
- --config=/config/config.yaml
|
- --config=/config/config.yaml
|
||||||
- --content-server=http://localhost:9090
|
- --content-server=http://127.0.0.1:9090
|
||||||
- --agree-eula
|
- --agree-eula
|
||||||
image: docker.io/criticalstack/quake:v1.0.5
|
image: docker.io/criticalstack/quake:latest
|
||||||
name: server
|
name: server
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
@ -40,7 +40,7 @@ spec:
|
|||||||
- q3
|
- q3
|
||||||
- content
|
- content
|
||||||
- --seed-content-url=http://content.quakejs.com
|
- --seed-content-url=http://content.quakejs.com
|
||||||
image: docker.io/criticalstack/quake:v1.0.5
|
image: docker.io/criticalstack/quake:latest
|
||||||
name: content-server
|
name: content-server
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 9090
|
- containerPort: 9090
|
||||||
@ -57,11 +57,11 @@ spec:
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: quakejs
|
name: quake
|
||||||
spec:
|
spec:
|
||||||
type: NodePort
|
type: NodePort
|
||||||
selector:
|
selector:
|
||||||
run: quakejs
|
run: quake
|
||||||
ports:
|
ports:
|
||||||
- port: 8080
|
- port: 8080
|
||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
@ -55,10 +56,7 @@ func NewRouter(cfg *Config) (*echo.Echo, error) {
|
|||||||
return c.JSONPretty(http.StatusOK, files, " ")
|
return c.JSONPretty(http.StatusOK, files, " ")
|
||||||
})
|
})
|
||||||
e.GET("/assets/*", func(c echo.Context) error {
|
e.GET("/assets/*", func(c echo.Context) error {
|
||||||
path := filepath.Join(cfg.AssetsDir, c.Param("*"))
|
path := filepath.Join(cfg.AssetsDir, trimAssetName(c.Param("*")))
|
||||||
d, f := filepath.Split(path)
|
|
||||||
f = f[strings.Index(f, "-")+1:]
|
|
||||||
path = filepath.Join(d, f)
|
|
||||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||||
return c.String(http.StatusNotFound, "file not found")
|
return c.String(http.StatusNotFound, "file not found")
|
||||||
}
|
}
|
||||||
@ -131,3 +129,11 @@ func NewRouter(cfg *Config) (*echo.Echo, error) {
|
|||||||
})
|
})
|
||||||
return e, nil
|
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