inngest / inngestgo

Durable execution in Go with the Golang Inngest SDK. Write durable functions in your existing app.
https://pkg.go.dev/github.com/inngest/inngestgo
Apache License 2.0
29 stars 3 forks source link

Setup inngest for local development with docker #69

Open AbdelilahOu opened 2 weeks ago

AbdelilahOu commented 2 weeks ago

I have been trying to setup inngest with docker and docker-compose but, I keep getting this error:

2024/11/05 10:04:49 ERROR error registering functions error="error performing registration request: error making request: Post \"http://127.0.0.1:8288/fn/register\": dial tcp 127.0.0.1:8288: connect: connection refused"

Im using golang:1.23 And this is my main.go file:

package main

import (
    "fmt"
    "log"
    "net/http"

    "github.com/AbdelilahOu/Mahalli-functions/config"
    funcs "github.com/AbdelilahOu/Mahalli-functions/functions"
    "github.com/inngest/inngestgo"
)

func main() {
    config, err := config.LoadConfig()
    if err != nil {
        log.Fatal("cant load env config: ", err)
    }
    handler := inngestgo.NewHandler("mahalli", inngestgo.HandlerOpts{})
    uploadImageF := inngestgo.CreateFunction(
        inngestgo.FunctionOpts{
            ID:   "upload-image",
            Name: "Upload Image flow",
        },
        inngestgo.EventTrigger("api/upload.image", nil),
        funcs.OptimizeImageAndUpload,
    )
    sendEmailF := inngestgo.CreateFunction(
        inngestgo.FunctionOpts{
            ID:   "send-welcome-email",
            Name: "Send Welcome Emaol flow",
        },
        inngestgo.EventTrigger("api/send.welcome.email", nil),
        funcs.OptimizeImageAndUpload,
    )
    handler.Register(uploadImageF, sendEmailF)
    if err := http.ListenAndServe(fmt.Sprintf(":%s", config.PORT), handler); err != nil {
        log.Fatal("cant run server: ", err)
    }
}

also my docker compose file:

services:
  app:
    build:
      context: .
      target: final
    environment:
      - INNGEST_DEV=1
      - PORT=8080
      - INNGEST_BASE_URL=http://inngest:8288/
    ports:
      - "8080:8080"

  inngest:
    image: inngest/inngest:v0.27.0
    command: "inngest dev -u http://app:8080/"
    ports:
      - "8288:8288"
darwin67 commented 16 hours ago

Try removing INNGEST_BASE_URL from app and replace INNGEST_DEV=http://inngest:8288 instead.