Skip to content

Commit f82c45d

Browse files
committed
Hello world!
0 parents  commit f82c45d

28 files changed

+3096
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
repos

Dockerfile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Start from the latest golang base image
2+
FROM golang:latest as builder
3+
4+
# Add Maintainer Info
5+
LABEL maintainer="Honza Pokorny <[email protected]>"
6+
7+
# Set the Current Working Directory inside the container
8+
WORKDIR /app
9+
10+
# Copy go mod and sum files
11+
COPY go.mod go.sum ./
12+
13+
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
14+
RUN go mod download
15+
16+
# Copy the source from the current directory to the Working Directory inside the container
17+
COPY . .
18+
19+
# Build the Go app
20+
RUN CGO_ENABLED=0 go build -o smithy .
21+
22+
######## Start a new stage from scratch #######
23+
FROM alpine:latest
24+
25+
RUN apk --no-cache add ca-certificates
26+
27+
WORKDIR /root/
28+
29+
# Copy the Pre-built binary file from the previous stage
30+
COPY --from=builder /app/templates templates
31+
COPY --from=builder /app/config.yaml .
32+
COPY --from=builder /app/smithy .
33+
34+
# Expose port 8080 to the outside world
35+
EXPOSE 8080
36+
37+
# Command to run the executable
38+
CMD ["./smithy"]

LICENSE

+674
Large diffs are not rendered by default.

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
BUILD_VERSION ?= $(shell git describe --always --abbrev=40 --dirty)
2+
3+
LDFLAGS="-X github.com/honza/smithy/cmd.SmithyVersion=${BUILD_VERSION}"
4+
5+
all:
6+
statik -src=include -dest=pkg -f -m
7+
CGO_ENABLED=0 go build -ldflags $(LDFLAGS) -o smithy main.go
8+
9+
gofmt:
10+
go fmt ./pkg/... ./cmd/...

README.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Smithy
2+
===============================================================================
3+
4+
*smithy* (n) A blacksmith's shop; a forge.
5+
6+
Smithy is a web frontend for git repositories. It's implemented entirely in
7+
Golang, compiles to a single binary, and it's fast and easy to deploy. Smithy
8+
is an alternative to cgit or gitweb, and doesn't seek to compete with Gitea and
9+
the like.
10+
11+
* Golang
12+
* Single binary
13+
* Easy to deploy
14+
* Fast
15+
* Customizable
16+
* Free software
17+
* Javascript-free
18+
19+
Building
20+
-------------------------------------------------------------------------------
21+
22+
The only dependency is [Golang](https://golang.org/).
23+
24+
```
25+
$ git clone https://github.com/honza/smithy
26+
$ make
27+
$ ./smithy --help
28+
```
29+
30+
Installing
31+
-------------------------------------------------------------------------------
32+
33+
```
34+
$ smithy generate > config.yaml
35+
$ smithy serve --config smithy.yaml
36+
```
37+
38+
Configuration
39+
-------------------------------------------------------------------------------
40+
41+
``` yaml
42+
title: Smithy, a lightweight git forge
43+
description: Publish your git repositories with ease
44+
port: 3456
45+
git:
46+
root: "/var/www/git"
47+
repos:
48+
- path: "some-cool-project"
49+
slug: "some-cool-project"
50+
title: "Some Cool Project"
51+
description: "Something really cool to change the world"
52+
- path: "ugly-hacks"
53+
exclude: true
54+
55+
static:
56+
root:
57+
prefix: /static/
58+
59+
templates:
60+
dir:
61+
```
62+
63+
Customizing templates and css
64+
-------------------------------------------------------------------------------
65+
66+
Out of the box, smithy bundles templates and css in the binary. Setting
67+
`static.root`, and `templates.dir` to empty string will cause smithy to use the
68+
bundled assets.
69+
70+
If you'd like to customize the templates or the css, copy the `include`
71+
directory somewhere, and then set `static.root`, and `templates.dir` to that
72+
directory.
73+
74+
Demo
75+
-------------------------------------------------------------------------------
76+
77+
Smithy is currently hosting [itself on my
78+
domain](https://smithy.honza.ca/smithy).
79+
80+
License
81+
-------------------------------------------------------------------------------
82+
83+
This program is free software: you can redistribute it and/or modify it under
84+
the terms of the GNU General Public License as published by the Free Software
85+
Foundation, either version 3 of the License, or (at your option) any later
86+
version.
87+
88+
This program is distributed in the hope that it will be useful, but WITHOUT ANY
89+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
90+
PARTICULAR PURPOSE. See the GNU General Public License for more details.
91+
92+
You should have received a copy of the GNU General Public License along with
93+
this program. If not, see <https://www.gnu.org/licenses/>.

cmd/generate-default-configuration.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// smithy --- the git forge
2+
// Copyright (C) 2020 Honza Pokorny <[email protected]>
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
package cmd
18+
19+
import (
20+
"github.com/honza/smithy/pkg/smithy"
21+
"github.com/spf13/cobra"
22+
)
23+
24+
var generateDefaultConfigurationCmd = &cobra.Command{
25+
Use: "generate",
26+
Short: "Generate the default smithy configuration",
27+
Run: func(cmd *cobra.Command, args []string) {
28+
smithy.GenerateDefaultConfig()
29+
},
30+
}

cmd/root.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// smithy --- the git forge
2+
// Copyright (C) 2020 Honza Pokorny <[email protected]>
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
package cmd
18+
19+
import (
20+
"fmt"
21+
"os"
22+
23+
"github.com/spf13/cobra"
24+
)
25+
26+
var rootCmd = &cobra.Command{
27+
Use: "smithy",
28+
Short: "Smithy Git Forge",
29+
Long: `A lightweight git forge`,
30+
Run: func(cmd *cobra.Command, args []string) {
31+
cmd.Help()
32+
},
33+
}
34+
35+
func Execute() {
36+
if err := rootCmd.Execute(); err != nil {
37+
fmt.Println(err)
38+
os.Exit(1)
39+
}
40+
}
41+
42+
func init() {
43+
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file path (default is config.yaml)")
44+
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "")
45+
rootCmd.AddCommand(generateDefaultConfigurationCmd)
46+
rootCmd.AddCommand(serveCmd)
47+
rootCmd.AddCommand(versionCmd)
48+
}

cmd/serve.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// smithy --- the git forge
2+
// Copyright (C) 2020 Honza Pokorny <[email protected]>
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
package cmd
18+
19+
import (
20+
"github.com/honza/smithy/pkg/smithy"
21+
"github.com/spf13/cobra"
22+
)
23+
24+
var cfgFile string
25+
var debug bool
26+
27+
var serveCmd = &cobra.Command{
28+
Use: "serve",
29+
Short: "Start the smithy server",
30+
Run: func(cmd *cobra.Command, args []string) {
31+
smithy.StartServer(cfgFile, debug)
32+
},
33+
}

cmd/version.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// smithy --- the git forge
2+
// Copyright (C) 2020 Honza Pokorny <[email protected]>
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
package cmd
18+
19+
import (
20+
"fmt"
21+
"github.com/spf13/cobra"
22+
)
23+
24+
var SmithyVersion string
25+
26+
var versionCmd = &cobra.Command{
27+
Use: "version",
28+
Short: "Show smithy version",
29+
Run: func(cmd *cobra.Command, args []string) {
30+
if SmithyVersion == "" {
31+
fmt.Println("dev")
32+
return
33+
}
34+
fmt.Println(SmithyVersion)
35+
},
36+
}

go.mod

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module github.com/honza/smithy
2+
3+
go 1.15
4+
5+
require (
6+
github.com/alecthomas/chroma v0.8.1
7+
github.com/gin-gonic/gin v1.6.3
8+
github.com/go-git/go-git/v5 v5.1.0
9+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
10+
github.com/modern-go/reflect2 v1.0.1 // indirect
11+
github.com/rakyll/statik v0.1.7
12+
github.com/spf13/cobra v1.0.0
13+
github.com/yuin/goldmark v1.2.1
14+
gopkg.in/yaml.v2 v2.2.8
15+
)

0 commit comments

Comments
 (0)