Skip to content

Commit

Permalink
add deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Fajar-Islami committed Oct 17, 2024
1 parent f75d5df commit 9377400
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ jobs:
docker login ${{env.REGISTRY}} -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
echo ${{ vars.ENV }} > .env
docker ps -a --filter "ancestor=${{ env.CONTAINER_NAME }}" --format "{{.ID}}" | xargs -r docker rm
docker run --add-host=host.docker.internal:host-gateway --name ${{ env.CONTAINER_NAME }}_${{ github.sha }} -v ./.env:/.env -d --restart=on-failure:5 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
# docker ps -a --filter "ancestor=${{ env.CONTAINER_NAME }}" --format "{{.ID}}" | xargs -r docker rm
# docker run --add-host=host.docker.internal:host-gateway --name ${{ env.CONTAINER_NAME }}_${{ github.sha }} -v ./.env:/.env -d --restart=on-failure:5 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
# echo ${{ env.CONTAINER_NAME }}_${{ github.sha }}
# docker images --format "{{.Repository}}:{{.Tag}}" | grep "^${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | grep -v ":${{ github.sha }}" | xargs -r docker rmi
# docker login ${{env.REGISTRY}} -u ${{github.actor}} -p ${{secrets.GITHUB_TOKEN}}
Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

var (
PORT string
BOT_TOKEN string
JOKESBAPAKBAPAKURI string
ENVIRONMENT string
Expand All @@ -42,7 +43,7 @@ func init() {
log.Println("err read env file : ", err)
}

log.Println("ReadInConfig", err)
PORT = os.Getenv("PORT")
BOT_TOKEN = os.Getenv("BOT_TOKEN")
JOKESBAPAKBAPAKURI = os.Getenv("JOKESBAPAKBAPAKURI")
ENVIRONMENT = os.Getenv("ENVIRONMENT")
Expand Down Expand Up @@ -90,13 +91,14 @@ func main() {
router.GET("/health", healthCheck)

server := http.Server{
Addr: "localhost:8000",
Addr: "localhost:" + PORT,
Handler: router,
}

ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()

fmt.Println("Running on PORT", PORT)
go func() {
if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Fatalf("listen and serve returned err: %v", err)
Expand All @@ -115,7 +117,7 @@ func main() {
}

func healthCheck(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
fmt.Fprintf(w, "Hello world")
fmt.Fprintf(w, "Fajar Bot is up")
}

// This function will be called (due to AddHandler above) every time a new
Expand Down

0 comments on commit 9377400

Please sign in to comment.