Working initial setup
parent
1184a2fb33
commit
ae5965f2e1
@ -0,0 +1,21 @@
|
||||
ARG BASE_IMAGE
|
||||
FROM ${BASE_IMAGE:-golang:1.22}
|
||||
ARG REPO_NAME
|
||||
ARG REPO_SHA
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Download Go modules
|
||||
COPY go.mod ./
|
||||
RUN go mod download
|
||||
|
||||
COPY *.go ./
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /fluxfeed
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
LABEL io.runcible.repo-name="${REPO_NAME}" \
|
||||
io.runcible.repo-sha="${REPO_SHA}"
|
||||
|
||||
CMD ["/fluxfeed"]
|
@ -0,0 +1,36 @@
|
||||
.DEFAULT_GOAL := build
|
||||
BASE_GOLANG_IMAGE := golang:1.22
|
||||
IMAGE_NAME ?= androiddrew/fluxfeed
|
||||
|
||||
fmt:
|
||||
go fmt ./...
|
||||
.PHONY:fmt
|
||||
|
||||
lint: fmt
|
||||
revive ./...
|
||||
.PHONY:lint
|
||||
|
||||
vet: fmt
|
||||
go vet ./...
|
||||
.PHONY:vet
|
||||
|
||||
build: vet
|
||||
go build -o ./fluxfeed .
|
||||
.PHONY:build
|
||||
|
||||
clean:
|
||||
rm -rf ./fluxfeed
|
||||
.PHONY:clean
|
||||
|
||||
docs:
|
||||
echo "Starting godocs on http://localhost:8000"
|
||||
godoc -http=:8000
|
||||
.PHONY:docs
|
||||
|
||||
image:
|
||||
docker buildx build --platform linux/amd64 \
|
||||
--build-arg BASE_IMAGE=$(BASE_GOLANG_IMAGE) \
|
||||
--build-arg REPO_NAME=$(IMAGE_NAME) \
|
||||
--build-arg REPO_SHA=$(shell git rev-parse HEAD) \
|
||||
-t $(IMAGE_NAME) ./
|
||||
.PHONY: image
|
@ -0,0 +1,3 @@
|
||||
module git.runcible.io/androiddrew/fluxfeed
|
||||
|
||||
go 1.22.5
|
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
const FluxGreeting string = "Welcome to Flux Feed\n"
|
||||
|
||||
func HelloFluxFeed(out io.Writer) {
|
||||
fmt.Fprint(out, FluxGreeting)
|
||||
}
|
||||
|
||||
func main() {
|
||||
HelloFluxFeed(os.Stdout)
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCliGreeting(t *testing.T) {
|
||||
buffer := &bytes.Buffer{}
|
||||
|
||||
HelloFluxFeed(buffer)
|
||||
got := buffer.String()
|
||||
want := FluxGreeting
|
||||
|
||||
if got != want {
|
||||
t.Errorf("Got %s but wanted %s", got, want)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue