Skip to content

Commit

Permalink
use smaller executable, bump v1 (#11)
Browse files Browse the repository at this point in the history
* use smaller executable, bump v1

Signed-off-by: Clavianus Juneardo <[email protected]>

* utilize goreleaser for versioning

Signed-off-by: Clavianus Juneardo <[email protected]>

* remove anchor

Signed-off-by: Clavianus Juneardo <[email protected]>
  • Loading branch information
clavinjune authored Apr 15, 2022
1 parent 46aecd5 commit edbd518
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
33 changes: 16 additions & 17 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,50 @@
# Make sure to check the documentation at https://goreleaser.com
archives:
- format: binary
wrap_in_directory: false
wrap_in_directory: "false"
before:
hooks:
- make check
builds:
- id: amd64
- &build
id: arm64
env:
- CGO_ENABLED=0
goarch:
- amd64
- arm64
goos:
- linux
- windows
- darwin
- linux
hooks:
post: upx -9 {{ .Path }}
ldflags:
- "-s -w"
- id: arm64
env:
- CGO_ENABLED=0
- <<: *build
id: amd64
goarch:
- arm64
- amd64
goos:
- linux
- darwin
hooks:
post: upx -9 {{ .Path }}
ldflags:
- "-s -w"
- linux
- windows
checksum:
name_template: 'checksums.txt'
dockers:
- build_flag_templates:
- "--label=org.opencontainers.image.authors=Clavin June"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.description={{.ReleaseNotes}}"
- "--label=org.opencontainers.image.description=A Lightweight HTTP Server Built on Top of Go"
- "--label=org.opencontainers.image.url=https://serve.clavinjune.dev"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.base.name=gcr.io/distroless/static:latest-arm64@sha256:6017b5802f96702dd66066a351e6e84ab003b768042d83fdbfb5a1159824425a"
image_templates:
- "ghcr.io/clavinjune/serve:{{ .Version }}"
- "ghcr.io/clavinjune/serve:{{ .ShortCommit }}"
- "ghcr.io/clavinjune/serve:latest"
skip_push: auto
goos: "linux"
goarch: "arm64"
extra_files:
- src/
changelog:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM gcr.io/distroless/static:latest
FROM gcr.io/distroless/static:latest-arm64@sha256:6017b5802f96702dd66066a351e6e84ab003b768042d83fdbfb5a1159824425a
WORKDIR /app
COPY . .
ENTRYPOINT [ "/app/serve", "-r", "/app/src" ]
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,39 @@ A Lightweight HTTP Server Built on Top of Go

```bash
# chmod +x serve_{version}_{os}_{arch}
$ chmod +x serve_0.3.9_linux_amd64
$ ./serve_0.3.9_linux_amd64 -v
serve v0.3.9
$ chmod +x serve_1.0.0_linux_amd64
$ ./serve_1.0.0_linux_amd64 -v
serve v1.0.0
```

### Via Go Install

```bash
$ go install github.com/ClavinJune/serve@latest
go: downloading github.com/ClavinJune/serve v0.3.9
go: downloading github.com/ClavinJune/serve v1.0.0
$ serve -v
serve v0.3.9
serve v1.0.0
```

### Via Go Run

```bash
$ go run github.com/ClavinJune/serve@latest -v
serve v0.3.9
serve v1.0.0
```

### Via Docker

```bash
$ docker run -it --rm ghcr.io/clavinjune/serve:latest -v
serve v0.3.9
serve v1.0.0
```

### Via Podman

```bash
$ podman run -it --rm ghcr.io/clavinjune/serve:latest -v
serve v0.3.9
serve v1.0.0
```

## Usage
Expand Down
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"strings"
"syscall"
"time"

"github.com/ClavinJune/serve/internal"
)

const (
version string = "v0.3.9"
var (
version = "dev"
buildBy = "dev"
commit = "n/a"
date = "0001-01-01 00:00:00 +0000 UTC"
)

var (
Expand Down Expand Up @@ -83,7 +87,10 @@ func mustGetServer(rootDir string, isSpa bool) *http.Server {

func main() {
if *versionFlag {
fmt.Println("serve", version)
fmt.Printf("serve %s-%s %s/%s BuildBy=%s BuildDate=%s",
version, commit,
runtime.GOOS, runtime.GOARCH,
buildBy, date)
return
}

Expand Down

0 comments on commit edbd518

Please sign in to comment.