Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced documentation #6

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/pushimage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: build-push-image

on:
push:
tags:
- 'v*'

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
tags: ghcr.io/tlinden/ephemerup:${{ github.ref_name}}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ buildlocalctl:
make -C upctl

buildlocal:
go build -ldflags "-X 'github.com/tlinden/ephemerup/cfg.VERSION=$(VERSION)'" -o $(DAEMON)
# go build -ldflags "-X 'github.com/tlinden/ephemerup/cfg.VERSION=$(VERSION)'" -o $(DAEMON)
CGO_LDFLAGS='-static' go build -tags osusergo,netgo -ldflags "-extldflags=-static -s -X 'github.com/tlinden/ephemerup/cfg.VERSION=$(VERSION)'" -o $(DAEMON)

buildimage: clean
docker-compose --verbose build
Expand Down
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,21 @@ authorize. A user can only manage uploads within that context. Think

## Installation

Since the software is currently being developed, there are no binary
releases available yet. You'll need a go build environment. Just run
`make` to build everything.
### Deploy server using pre-built docker file

A ready to use ephemerup server image is available on
[ghcr.io](https://ghcr.io/tlinden/ephemerup). Supported tags are:
`latest` or a github release tag.

To try it locally with docker:

```
docker run -dp 8080:8080 --name eph \
ghcr.io/tlinden/ephemerup:latest \
-LogLevel=info
```

### Build Dockerfile

There's a `Dockerfile` available for the server so you can build and run it using docker:
```
Expand All @@ -68,6 +80,43 @@ docker-compose run ephemerup
```
Then use the client to test it.

### Install from binary package

Go to the [Releases](https://github.com/TLINDEN/ephemerup/releases)
page and download the latest tarball for your platform. Unpack it and
execute `make install` inside the created directory.

This installs both the server `ephemerupd` and the client `upctl`.

If you only need the client, just grab the tarball and extract just
the client, copy it to your bin folder and you're good to go.

### Deploy on Kubernetes using the Helm chart

```
helm repo add tlinden https://tlinden.github.io/ephemerup/
helm repo update
helm upgrade --install ephemerup tlinden/ephemerup --namespace ephemerup --create-namespace
```

Refer to the [chart documentation](https://github.com/TLINDEN/ephemerup/tree/main/charts/ephemerup) for help.

For starters, create a minimal `values.yaml` like this one:
```yaml
image:
tag: "v0.0.3"
``**

**Please note that the helm chart doesn't deploy a loadbalancer, you need to do this yourself, if needed.**

### Build from source

To build from source, you'll need a go build environment.

Clone the git repo
Just run `make` to build everything.


## Server Usage

```
Expand Down
3 changes: 1 addition & 2 deletions api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down Expand Up @@ -108,7 +107,7 @@ func AuthValidateAPIKey(c *fiber.Ctx, key string) (bool, error) {
return true, nil
}

// actual key comparision
// actual key comparison
for _, apicontext := range Apikeys {
hashedAPIKey := sha256.Sum256([]byte(apicontext.Key))
hashedKey := sha256.Sum256([]byte(key))
Expand Down
1 change: 0 additions & 1 deletion api/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down
1 change: 0 additions & 1 deletion api/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down
1 change: 0 additions & 1 deletion api/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down
1 change: 0 additions & 1 deletion api/fileio.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down
3 changes: 1 addition & 2 deletions api/form_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down Expand Up @@ -63,7 +62,7 @@ func FormCreate(c *fiber.Ctx, cfg *cfg.Config, db *Db) error {
}
entry.Context = apicontext

// extract auxilliary form data (expire field et al)
// extract auxiliary form data (expire field et al)
if err := c.BodyParser(&formdata); err != nil {
return JsonStatus(c, fiber.StatusInternalServerError,
"bodyparser error : "+err.Error())
Expand Down
1 change: 0 additions & 1 deletion api/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down
11 changes: 7 additions & 4 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
"errors"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/compress"
"github.com/gofiber/fiber/v2/middleware/cors"
Expand Down Expand Up @@ -131,6 +131,9 @@ func Runserver(conf *cfg.Config, args []string) error {
return FormPage(c, conf, db, shallExpire)
})

router.Get("/status", func(c *fiber.Ctx) error {
return Status(c, conf)
})
}

// setup cleaner
Expand Down Expand Up @@ -197,8 +200,8 @@ func SetupServer(conf *cfg.Config) *fiber.App {
}

/*
Wrapper to respond with proper json status, message and code,
shall be prepared and called by the handlers directly.
Wrapper to respond with proper json status, message and code,
shall be prepared and called by the handlers directly.
*/
func JsonStatus(c *fiber.Ctx, code int, msg string) error {
success := true
Expand All @@ -215,7 +218,7 @@ func JsonStatus(c *fiber.Ctx, code int, msg string) error {
}

/*
Used for non json-aware handlers, called by server
Used for non json-aware handlers, called by server
*/
func SendResponse(c *fiber.Ctx, msg string, err error) error {
if err != nil {
Expand Down
24 changes: 24 additions & 0 deletions api/status_handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package api

import (
"github.com/gofiber/fiber/v2"
"github.com/tlinden/ephemerup/cfg"
"github.com/tlinden/ephemerup/common"
)

func Status(c *fiber.Ctx, cfg *cfg.Config) error {
res := &common.Response{}
res.Success = true
res.Code = fiber.StatusOK
res.Message = "up and running"
return c.Status(fiber.StatusOK).JSON(res)
}
3 changes: 1 addition & 2 deletions api/upload_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down Expand Up @@ -86,7 +85,7 @@ func UploadPost(c *fiber.Ctx, cfg *cfg.Config, db *Db) error {
}
entry.Members = members

// extract auxilliary form data (expire field et al)
// extract auxiliary form data (expire field et al)
if err := c.BodyParser(&formdata); err != nil {
return JsonStatus(c, fiber.StatusInternalServerError,
"bodyparser error : "+err.Error())
Expand Down
1 change: 0 additions & 1 deletion api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package api

import (
Expand Down
2 changes: 1 addition & 1 deletion cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"time"
)

const Version string = "v0.0.2"
const Version string = "v0.0.3"

var VERSION string // maintained by -x

Expand Down
21 changes: 21 additions & 0 deletions charts/ephemerup/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
21 changes: 21 additions & 0 deletions charts/ephemerup/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: ephemerup
description: |
A Helm chart for Ephemerup.

type: application

sources:
- https://github.com/tlinden/ephemerup

version: 1.0.0

appVersion: "0.0.2"

dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
tags:
- bitnami-common
version: 1.x.x
# icon: ""
Loading