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

Setup inngest for local development with docker #69

Open
AbdelilahOu opened this issue Nov 5, 2024 · 2 comments
Open

Setup inngest for local development with docker #69

AbdelilahOu opened this issue Nov 5, 2024 · 2 comments

Comments

@AbdelilahOu
Copy link

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
Copy link
Contributor

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

@AbdelilahOu
Copy link
Author

hello @darwin67 thanks for the comment but I don't that works either now I only have two env variables PORT=8080 and INNGEST_DEV=http://inngest:8288/ but inggest still cant find the functions
Im pretty sure the functions are running correctly :
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants