diff --git a/.gitea/workflows/docker-publish.yml b/.gitea/workflows/docker-publish.yml index e650a29..a1eb260 100644 --- a/.gitea/workflows/docker-publish.yml +++ b/.gitea/workflows/docker-publish.yml @@ -1,28 +1,32 @@ -name: Docker Publish +name: Docker Release Build on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v*' # Reagiert auf Tags die mit 'v' beginnen, z.B. v1.0.2 jobs: - build-and-push: - runs-on: ubuntu-latest + push_to_registry: + runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@main + uses: actions/checkout@v4 - - name: Set up Docker Buildx - run: docker buildx create --use - - - name: Login to Gitea Container Registry - run: | - echo "$GITEA_TOKEN" | docker login -u "$GITEA_ACTOR" --password-stdin gitea.scu.si + - name: Login to Gitea + uses: docker/login-action@v3 + with: + registry: ${{ vars.REGISTRY_URL }} # gitea.scu.si + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} - name: Build and push - run: | - docker buildx build \ - --platform linux/amd64,linux/arm64 \ - --push \ - -t gitea.scu.si/${GITEA_REPOSITORY}/mdhost:latest \ - -t gitea.scu.si/${GITEA_REPOSITORY}/mdhost:$GITEA_REF_NAME \ - . + uses: docker/build-push-action@v5 + with: + context: . + push: true + # Hier wird die Git-Referenz automatisch als Docker-Tag genutzt + #tags: gitea.scu.si/florianwalther/mdhost:${{ gitea.ref_name }} + build-args: | + APP_VERSION=${{ gitea.ref_name }} + tags: | + gitea.scu.si/florian.walther/mdhost:${{ gitea.ref_name }} + gitea.scu.si/florian.walther/mdhost:latest diff --git a/Dockerfile b/Dockerfile index cafdaa3..05461e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,9 @@ RUN go mod download # Copy source code COPY . . -# Build statically -RUN CGO_ENABLED=0 GOOS=linux go build -ldflags='-w -s' -o mdhost . +# Build statically with version +ARG APP_VERSION=dev +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s -X main.version=${APP_VERSION}" -o mdhost . # Final scratch image FROM scratch diff --git a/README.md b/README.md index e0818da..983f7f4 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ The creation timestamp is stored in the file's `CreatedAt` field and persists ac ## Docker +A pre-built Docker image is available from `gitea.scu.si/florian.walther/mdhost:latest`. + ### Build the Image ```bash diff --git a/go.mod b/go.mod index c1ace75..e789b46 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,12 @@ module mdhost go 1.26.2 require ( + github.com/yuin/goldmark v1.8.2 + github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594 + golang.org/x/crypto v0.50.0 +) + +require ( github.com/alecthomas/chroma v0.10.0 // indirect - github.com/alecthomas/chroma/v2 v2.24.1 // indirect github.com/dlclark/regexp2 v1.12.0 // indirect - github.com/yuin/goldmark v1.8.2 // indirect - github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594 // indirect - golang.org/x/crypto v0.50.0 // indirect ) diff --git a/go.sum b/go.sum index 13779f8..c234b40 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,15 @@ github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= -github.com/alecthomas/chroma/v2 v2.24.1 h1:m5ffpfZbIb++k8AqFEKy9uVgY12xIQtBsQlc6DfZJQM= -github.com/alecthomas/chroma/v2 v2.24.1/go.mod h1:l+ohZ9xRXIbGe7cIW+YZgOGbvuVLjMps/FYN/CwuabI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8= github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.4.5/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg= github.com/yuin/goldmark v1.8.2 h1:kEGpgqJXdgbkhcOgBxkC0X0PmoPG1ZyoZ117rDVp4zE= @@ -18,4 +19,5 @@ github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594/go.mod golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI= golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 7a4e0b2..6643520 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ import ( "time" "github.com/yuin/goldmark" + "github.com/yuin/goldmark/extension" "github.com/yuin/goldmark-highlighting" "golang.org/x/crypto/bcrypt" ) @@ -26,6 +27,7 @@ var ( port = ":8080" markdown = newMarkdownRenderer() dataMu sync.RWMutex + version = "dev" ) // ListFormat configures how files are rendered in the index @@ -83,9 +85,12 @@ var ( func newMarkdownRenderer() goldmark.Markdown { return goldmark.New( - goldmark.WithExtensions(highlighting.NewHighlighting( - highlighting.WithStyle("github"), - )), + goldmark.WithExtensions( + extension.Table, + highlighting.NewHighlighting( + highlighting.WithStyle("github"), + ), + ), ) } @@ -466,9 +471,17 @@ const css = `