Skip to content

Commit

Permalink
Rewrite, expiry mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilsol committed Nov 6, 2020
1 parent 658dc47 commit 9627d92
Show file tree
Hide file tree
Showing 16 changed files with 551 additions and 225 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: build

on: [push, pull_request]

jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
file: yeet-linux-amd64
args: --best --lzma
strip: true
cgo: 0
- os: windows-latest
file: yeet-win-amd64.exe
args: -9
strip: false
cgo: 1
- os: macos-latest
file: yeet-osx-amd64
args: --best
strip: false
cgo: 1
steps:

- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.15

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build
run: go build -ldflags="-s -w" -v -o ${{ matrix.file }} .
env:
CGO_ENABLED: ${{ matrix.cgo }}

analyze:
name: Analyze
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.15

- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2

- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go

- name: Build
run: go build -ldflags="-s -w" -v -o yeet .
env:
CGO_ENABLED: 0

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
129 changes: 0 additions & 129 deletions .github/workflows/go.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: release

on:
push:
tags:
- v*

jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.15

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Log into GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@ modules.xml

# End of https://www.gitignore.io/api/go,jetbrains+all

www/
www/
dist/
61 changes: 61 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
before:
hooks:
- go mod download

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- 386
- arm
- arm64
- ppc64le
- s390x
goarm:
- 6
- 7
- 8
ignore:
- goos: linux
goarch: arm
goarm: 8

archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
allow_different_binary_count: true

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

dockers:
- image_templates:
- "ghcr.io/vilsol/yeet:{{ .Tag }}"
- "ghcr.io/vilsol/yeet:v{{ .Major }}"
- "ghcr.io/vilsol/yeet:v{{ .Major }}.{{ .Minor }}"
- "ghcr.io/vilsol/yeet:latest"
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
22 changes: 1 addition & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
FROM golang:1.15-alpine AS builder

LABEL org.opencontainers.image.source https://github.com/Vilsol/yeet

RUN apk add --no-cache git

WORKDIR $GOPATH/src/github.com/Vilsol/yeet/

ENV GO111MODULE=on

COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /yeet main.go

FROM scratch

COPY --from=builder /yeet /yeet

COPY yeet /
ENTRYPOINT ["/yeet"]
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Yeet

```
yeet is an in-memory indexed static file webserver
Usage:
yeet [command]
Expand All @@ -11,20 +9,23 @@ Available Commands:
serve Run the webserver
Flags:
--colors Force output with colors
-h, --help help for yeet
--host string Hostname to bind the webserver (default "0.0.0.0")
--log string The log level to output (default "info")
--paths strings Paths to serve on the webserver (default [./www])
--port int Port to run the webserver on (default 8080)
--colors Force output with colors
--expiry Use cache expiry
--expiry-interval duration Port to run the webserver on (default 10m0s)
--expiry-memory int Max memory usage in MB (default 128)
--expiry-shards int Cache shard count (default 64)
--expiry-time duration Lifetime of a cache entry (default 1h0m0s)
-h, --help help for yeet
--host string Hostname to bind the webserver (default "0.0.0.0")
--log string The log level to output (default "info")
--paths strings Paths to serve on the webserver (default [./www])
--port int Port to run the webserver on (default 8080)
Use "yeet [command] --help" for more information about a command.
Process finished with exit code 0
```

## Docker

```
docker run -v /path/to/data:/www -p 8080:8080 ghcr.io/vilsol/yeet:0.1.2
docker run -v /path/to/data:/www -p 8080:8080 ghcr.io/vilsol/yeet:latest
```
Loading

0 comments on commit 9627d92

Please sign in to comment.