diff --git a/README.md b/README.md index ba6987082b..f50215dec4 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,6 @@ Here you can find the most **delicious** recipes to cook delicious meals using o - [I18n](./i18n/README.md) - Internationalization support. - [JWT](./jwt/README.md) - Using JSON Web Tokens (JWT) for authentication. - [Kubernetes](./k8s/README.md) - Deploying applications to Kubernetes. -- [Local Development with Testcontainers](./local-development-testcontainers/README.md) - Local development with Testcontainers. - [Memgraph](./memgraph/README.md) - Using Memgraph. - [MinIO](./minio/README.md) - A simple application for uploading and downloading files from MinIO. - [MongoDB](./mongodb/README.md) - Connecting to a MongoDB database. @@ -76,6 +75,7 @@ Here you can find the most **delicious** recipes to cook delicious meals using o - [React](./react-router/README.md) - Using React. - [Recover Middleware](./recover/README.md) - Recover middleware for error handling. - [RSS Feed](./rss-feed/README.md) - Generating an RSS feed. +- [Seenode](./seenode/README.md) - Deploying to Seenode cloud platform. - [Server Timing](./server-timing/README.md) - Adding Server Timing headers to an application. - [Sessions + SQLite3](./sessions-sqlite3/README.md) - Using SQLite3 as a storage engine for user sessions. - [Socketio](./socketio/README.md) - A chatroom application using Socket.IO. @@ -90,7 +90,8 @@ Here you can find the most **delicious** recipes to cook delicious meals using o - [Tableflip Example](./tableflip/README.md) - Use tableflip for graceful upgrades in a Go application. - [Template](./template/README.md) - Setting up a Go application with template rendering. - [Template Asset Bundling](./template-asset-bundling/README.md) - Setting up a Go application with template rendering and asset bundling. -- [Todo App + Auth + GORM](./todo-app-with-auth-gorm/README.md) - A Todo application with authentication using GORM. +- [Todo App + Auth + GORM (Postgres + Testcontainers)](./local-development-testcontainers/README.md) - A Todo application with authentication using GORM and Postgres with Testcontainers for local development. +- [Todo App + Auth + GORM (SQLite)](./todo-app-with-auth-gorm/README.md) - A Todo application with authentication using GORM with SQLite database. - [Unit Testing](./unit-test/README.md) - Writing unit tests for a Go Fiber application. - [File Upload](./upload-file/README.md) - Handling file uploads in a Go application. - [URL Shortener](./url-shortener-api/README.md) - URL shortening service with a simple API. diff --git a/local-development-testcontainers/README.md b/local-development-testcontainers/README.md index ebb5e8bcc9..c1878364ea 100644 --- a/local-development-testcontainers/README.md +++ b/local-development-testcontainers/README.md @@ -6,7 +6,7 @@ description: A Todo application with authentication using GORM and Postgres. # Todo App with Auth using GORM and Testcontainers -[![Github](https://img.shields.io/static/v1?label=&message=Github&color=2ea44f&style=for-the-badge&logo=github)](https://github.com/gofiber/recipes/tree/master/todo-app-testcontainers-postgres) [![StackBlitz](https://img.shields.io/static/v1?label=&message=StackBlitz&color=2ea44f&style=for-the-badge&logo=StackBlitz)](https://stackblitz.com/github.com/gofiber/recipes/tree/master/todo-app-testcontainers-postgres) +[![Github](https://img.shields.io/static/v1?label=&message=Github&color=2ea44f&style=for-the-badge&logo=github)](https://github.com/gofiber/recipes/tree/master/local-development-testcontainers) [![StackBlitz](https://img.shields.io/static/v1?label=&message=StackBlitz&color=2ea44f&style=for-the-badge&logo=StackBlitz)](https://stackblitz.com/github/gofiber/recipes/tree/master/local-development-testcontainers) This project demonstrates a Todo application with authentication using GORM and Testcontainers. diff --git a/seenode/README.md b/seenode/README.md new file mode 100644 index 0000000000..a65c0ee620 --- /dev/null +++ b/seenode/README.md @@ -0,0 +1,93 @@ +--- +title: Seenode +keywords: [seenode, deploy, cloud] +description: Deploying to Seenode cloud platform. +--- + +# Seenode Deployment Example + +[![Github](https://img.shields.io/static/v1?label=&message=Github&color=2ea44f&style=for-the-badge&logo=github)](https://github.com/gofiber/recipes/tree/master/seenode) [![StackBlitz](https://img.shields.io/static/v1?label=&message=StackBlitz&color=2ea44f&style=for-the-badge&logo=StackBlitz)](https://stackblitz.com/github/gofiber/recipes/tree/master/seenode) + +This project demonstrates how to deploy a Go application using the Fiber framework on Seenode. + +## Prerequisites + +Ensure you have the following installed: + +- Golang +- [Fiber](https://github.com/gofiber/fiber) package +- [Seenode account](https://cloud.seenode.com) + +## Setup + +1. Clone the repository: + + ```sh + git clone https://github.com/gofiber/recipes.git + cd recipes/seenode + ``` + +2. Install dependencies: + + ```sh + go get + ``` + +3. Create a Seenode account and connect your repository: + - Go to [Seenode Dashboard](https://cloud.seenode.com) + - Create a new Web Service + - Connect your Git repository + +4. Configure deployment: + - **Build Command**: `go build -o app main.go` + - **Start Command**: `./app` + +5. Deploy the application: + + ```sh + git add . + git commit -m "Deploy to Seenode" + git push + ``` + +## Running the Application + +1. Open the application in your browser using the provided Seenode URL. + +## Example + +Here is an example `main.go` file for the Fiber application: + +```go +package main + +import ( + "fmt" + "log" + "os" + "github.com/gofiber/fiber/v2" +) + +func main() { + app := fiber.New() + + app.Get("/", func(c *fiber.Ctx) error { + return c.SendString("Hello, Welcome to seenode 👋") + }) + + port := os.Getenv("PORT") + if port == "" { + port = "8080" + } + + if err := app.Listen(fmt.Sprintf(":%s", port)); err != nil { + log.Fatalf("failed to start server: %v", err) + } +} +``` + +## References + +- [Fiber Documentation](https://docs.gofiber.io) +- [Seenode Documentation](https://seenode.com/docs/frameworks/go/fiber/) +- [Seenode](https://seenode.com) diff --git a/seenode/go.mod b/seenode/go.mod new file mode 100644 index 0000000000..1447f6da52 --- /dev/null +++ b/seenode/go.mod @@ -0,0 +1,19 @@ +module seenode-example + +go 1.23 + +require github.com/gofiber/fiber/v2 v2.52.9 + +require ( + github.com/andybalholm/brotli v1.1.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/rivo/uniseg v0.2.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.51.0 // indirect + github.com/valyala/tcplisten v1.0.0 // indirect + golang.org/x/sys v0.28.0 // indirect +) diff --git a/seenode/go.sum b/seenode/go.sum new file mode 100644 index 0000000000..339ed77946 --- /dev/null +++ b/seenode/go.sum @@ -0,0 +1,27 @@ +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw= +github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= +github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= +github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/seenode/main.go b/seenode/main.go new file mode 100644 index 0000000000..a3e34268ce --- /dev/null +++ b/seenode/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "log" + "os" + "github.com/gofiber/fiber/v2" +) + +func main() { + app := fiber.New() + + app.Get("/", func(c *fiber.Ctx) error { + return c.SendString("Hello, Welcome to seenode 👋") + }) + + port := os.Getenv("PORT") + if port == "" { + port = "8080" + } + + if err := app.Listen(fmt.Sprintf(":%s", port)); err != nil { + log.Fatalf("failed to start server: %v", err) + } +}