13 Commits

7 changed files with 101 additions and 33 deletions

View File

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO_VERSION: 1.19 GO_VERSION: 1.19
GOLANGCI_LINT_VERSION: v1.49.0 GOLANGCI_LINT_VERSION: v1.50.0
CGO_ENABLED: 0 CGO_ENABLED: 0
steps: steps:
@ -32,7 +32,7 @@ jobs:
# https://github.com/marketplace/actions/cache # https://github.com/marketplace/actions/cache
- name: Cache Go modules - name: Cache Go modules
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: ~/go/pkg/mod path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

View File

@ -31,7 +31,7 @@ jobs:
# https://github.com/marketplace/actions/cache # https://github.com/marketplace/actions/cache
- name: Cache Go modules - name: Cache Go modules
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
# In order: # In order:
# * Module download cache # * Module download cache

View File

@ -10,7 +10,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO_VERSION: 1.19 GO_VERSION: 1.19
SEIHON_VERSION: v0.9.0
CGO_ENABLED: 0 CGO_ENABLED: 0
steps: steps:
@ -27,12 +26,21 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Docker Login - name: dockerhub-login
env: uses: docker/login-action@v1
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} with:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} username: ${{ secrets.DOCKER_USERNAME }}
run: | password: ${{ secrets.DOCKER_PASSWORD }}
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
- name: ghcr-login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: traefiker
password: ${{ secrets.GHCR_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2

View File

@ -6,22 +6,13 @@ builds:
- windows - windows
- darwin - darwin
- linux - linux
- freebsd
- openbsd
goarch: goarch:
- amd64 - amd64
- '386'
- arm - arm
- arm64 - arm64
goarm: goarm:
- '7' - '7'
ignore:
- goos: darwin
goarch: '386'
- goos: openbsd
goarch: arm
changelog: changelog:
sort: asc sort: asc
filters: filters:
@ -43,38 +34,109 @@ archives:
files: files:
- LICENSE - LICENSE
docker_manifests:
- name_template: 'traefik/whoami:{{ .Tag }}'
image_templates:
- 'traefik/whoami:{{ .Tag }}-amd64'
- 'traefik/whoami:{{ .Tag }}-arm64'
- 'traefik/whoami:{{ .Tag }}-armv7'
- name_template: 'traefik/whoami:latest'
image_templates:
- 'traefik/whoami:{{ .Tag }}-amd64'
- 'traefik/whoami:{{ .Tag }}-arm64'
- 'traefik/whoami:{{ .Tag }}-armv7'
- name_template: 'traefik/whoami:v{{ .Major }}.{{ .Minor }}'
image_templates:
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-amd64'
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-arm64'
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-armv7'
- name_template: 'ghcr.io/traefik/whoami:{{ .Tag }}'
image_templates:
- 'ghcr.io/traefik/whoami:{{ .Tag }}-amd64'
- 'ghcr.io/traefik/whoami:{{ .Tag }}-arm64'
- 'ghcr.io/traefik/whoami:{{ .Tag }}-armv7'
- name_template: 'ghcr.io/traefik/whoami:latest'
image_templates:
- 'ghcr.io/traefik/whoami:{{ .Tag }}-amd64'
- 'ghcr.io/traefik/whoami:{{ .Tag }}-arm64'
- 'ghcr.io/traefik/whoami:{{ .Tag }}-armv7'
- name_template: 'ghcr.io/traefik/whoami:v{{ .Major }}.{{ .Minor }}'
image_templates:
- 'ghcr.io/traefik/whoami:v{{ .Major }}.{{ .Minor }}-amd64'
- 'ghcr.io/traefik/whoami:v{{ .Major }}.{{ .Minor }}-arm64'
- 'ghcr.io/traefik/whoami:v{{ .Major }}.{{ .Minor }}-armv7'
dockers: dockers:
- use: buildx - use: buildx
skip_push: true
goos: linux goos: linux
goarch: amd64 goarch: amd64
dockerfile: buildx.Dockerfile dockerfile: buildx.Dockerfile
image_templates: image_templates:
- 'traefik/whoami:dev-amd64'
- 'traefik/whoami:latest-amd64' - 'traefik/whoami:latest-amd64'
- 'traefik/whoami:{{ .Tag }}-amd64' - 'traefik/whoami:{{ .Tag }}-amd64'
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-amd64' - 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-amd64'
- 'ghcr.io/traefik/whoami:latest-amd64'
- 'ghcr.io/traefik/whoami:{{ .Tag }}-amd64'
- 'ghcr.io/traefik/whoami:v{{ .Major }}.{{ .Minor }}-amd64'
build_flag_templates: build_flag_templates:
- '--pull' - '--pull'
- '--label=org.opencontainers.image.created={{.Date}}' # https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
- '--label=org.opencontainers.image.title={{.ProjectName}}' - '--label=org.opencontainers.image.title={{.ProjectName}}'
- '--label=org.opencontainers.image.description=Tiny Go webserver that prints OS information and HTTP request to output'
- '--label=org.opencontainers.image.source={{.GitURL}}'
- '--label=org.opencontainers.image.url={{.GitURL}}'
- '--label=org.opencontainers.image.documentation={{.GitURL}}'
- '--label=org.opencontainers.image.created={{.Date}}'
- '--label=org.opencontainers.image.revision={{.FullCommit}}' - '--label=org.opencontainers.image.revision={{.FullCommit}}'
- '--label=org.opencontainers.image.version={{.Version}}' - '--label=org.opencontainers.image.version={{.Version}}'
- '--platform=linux/amd64'
- use: buildx - use: buildx
skip_push: true
goos: linux goos: linux
goarch: arm64 goarch: arm64
dockerfile: buildx.Dockerfile dockerfile: buildx.Dockerfile
image_templates: image_templates:
- 'traefik/whoami:dev-arm64'
- 'traefik/whoami:latest-arm64' - 'traefik/whoami:latest-arm64'
- 'traefik/whoami:{{ .Tag }}-arm64' - 'traefik/whoami:{{ .Tag }}-arm64'
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-arm64' - 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-arm64'
- 'ghcr.io/traefik/whoami:latest-arm64'
- 'ghcr.io/traefik/whoami:{{ .Tag }}-arm64'
- 'ghcr.io/traefik/whoami:v{{ .Major }}.{{ .Minor }}-arm64'
build_flag_templates: build_flag_templates:
- '--pull' - '--pull'
- '--label=org.opencontainers.image.created={{.Date}}' # https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
- '--label=org.opencontainers.image.title={{.ProjectName}}' - '--label=org.opencontainers.image.title={{.ProjectName}}'
- '--label=org.opencontainers.image.description=Tiny Go webserver that prints OS information and HTTP request to output'
- '--label=org.opencontainers.image.source={{.GitURL}}'
- '--label=org.opencontainers.image.url={{.GitURL}}'
- '--label=org.opencontainers.image.documentation={{.GitURL}}'
- '--label=org.opencontainers.image.created={{.Date}}'
- '--label=org.opencontainers.image.revision={{.FullCommit}}' - '--label=org.opencontainers.image.revision={{.FullCommit}}'
- '--label=org.opencontainers.image.version={{.Version}}' - '--label=org.opencontainers.image.version={{.Version}}'
- '--platform=linux/arm64'
- use: buildx
goos: linux
goarch: arm
goarm: '7'
dockerfile: buildx.Dockerfile
image_templates:
- 'traefik/whoami:latest-armv7'
- 'traefik/whoami:{{ .Tag }}-armv7'
- 'traefik/whoami:v{{ .Major }}.{{ .Minor }}-armv7'
- 'ghcr.io/traefik/whoami:latest-armv7'
- 'ghcr.io/traefik/whoami:{{ .Tag }}-armv7'
- 'ghcr.io/traefik/whoami:v{{ .Major }}.{{ .Minor }}-armv7'
build_flag_templates:
- '--pull'
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
- '--label=org.opencontainers.image.title={{.ProjectName}}'
- '--label=org.opencontainers.image.description=Tiny Go webserver that prints OS information and HTTP request to output'
- '--label=org.opencontainers.image.source={{.GitURL}}'
- '--label=org.opencontainers.image.url={{.GitURL}}'
- '--label=org.opencontainers.image.documentation={{.GitURL}}'
- '--label=org.opencontainers.image.created={{.Date}}'
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
- '--label=org.opencontainers.image.version={{.Version}}'
- '--platform=linux/arm/v7'

View File

@ -1,6 +1,4 @@
.PHONY: default check test build image publish-images .PHONY: default check test build image
TAG_NAME := $(shell git tag -l --contains HEAD)
IMAGE_NAME := traefik/whoami IMAGE_NAME := traefik/whoami
@ -17,6 +15,3 @@ check:
image: image:
docker build -t $(IMAGE_NAME) . docker build -t $(IMAGE_NAME) .
publish-images:
seihon publish -v "$(TAG_NAME)" -v "latest" --image-name $(IMAGE_NAME) --dry-run=false

View File

@ -104,6 +104,6 @@ services:
image: traefik/whoami image: traefik/whoami
command: command:
# It tells whoami to start listening on 2001 instead of 80 # It tells whoami to start listening on 2001 instead of 80
- --port 2001 - --port=2001
- --name iamfoo - --name=iamfoo
``` ```

3
app.go
View File

@ -50,6 +50,9 @@ func init() {
var upgrader = websocket.Upgrader{ var upgrader = websocket.Upgrader{
ReadBufferSize: 1024, ReadBufferSize: 1024,
WriteBufferSize: 1024, WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool {
return true
},
} }
func main() { func main() {