fix docker and deployment
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 42s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m50s

This commit is contained in:
matst80
2025-12-03 09:54:09 +01:00
parent ee5f54f0dd
commit dbdd759e16
4 changed files with 38 additions and 37 deletions

View File

@@ -71,6 +71,12 @@ RUN go build -trimpath -ldflags="-s -w \
-X main.BuildDate=${BUILD_DATE}" \ -X main.BuildDate=${BUILD_DATE}" \
-o /out/go-cart-inventory ./cmd/inventory -o /out/go-cart-inventory ./cmd/inventory
RUN go build -trimpath -ldflags="-s -w \
-X main.Version=${VERSION} \
-X main.GitCommit=${GIT_COMMIT} \
-X main.BuildDate=${BUILD_DATE}" \
-o /out/go-checkout-actor ./cmd/checkout
############################ ############################
# Runtime Stage # Runtime Stage
############################ ############################
@@ -79,6 +85,7 @@ FROM gcr.io/distroless/static-debian12:nonroot AS runtime
WORKDIR / WORKDIR /
COPY --from=build /out/go-cart-actor /go-cart-actor COPY --from=build /out/go-cart-actor /go-cart-actor
COPY --from=build /out/go-checkout-actor /go-checkout-actor
COPY --from=build /out/go-cart-backoffice /go-cart-backoffice COPY --from=build /out/go-cart-backoffice /go-cart-backoffice
COPY --from=build /out/go-cart-inventory /go-cart-inventory COPY --from=build /out/go-cart-inventory /go-cart-inventory

View File

@@ -115,9 +115,9 @@ func BuildCheckoutOrderPayload(grain *checkout.CheckoutGrain, meta *CheckoutMeta
Terms: fmt.Sprintf("%s/terms", meta.SiteUrl), Terms: fmt.Sprintf("%s/terms", meta.SiteUrl),
Checkout: fmt.Sprintf("%s/checkout?order_id={checkout.order.id}", meta.SiteUrl), Checkout: fmt.Sprintf("%s/checkout?order_id={checkout.order.id}", meta.SiteUrl),
Confirmation: fmt.Sprintf("%s/confirmation/{checkout.order.id}", meta.SiteUrl), Confirmation: fmt.Sprintf("%s/confirmation/{checkout.order.id}", meta.SiteUrl),
Notification: "https://cart.k6n.net/notification", Notification: "https://cart.k6n.net/payment/klarna/notification",
Validation: "https://cart.k6n.net/validate", Validation: "https://cart.k6n.net/payment/klarna/validate",
Push: "https://cart.k6n.net/push?order_id={checkout.order.id}", Push: "https://cart.k6n.net/payment/klarna/push?order_id={checkout.order.id}",
}, },
} }
@@ -201,7 +201,7 @@ func BuildAdyenCheckoutSession(grain *checkout.CheckoutGrain, meta *CheckoutMeta
MerchantAccount: "ElgigantenECOM", MerchantAccount: "ElgigantenECOM",
Channel: common.PtrString("Web"), Channel: common.PtrString("Web"),
ShopperIP: common.PtrString(meta.ClientIp), ShopperIP: common.PtrString(meta.ClientIp),
ReturnUrl: fmt.Sprintf("%s/adyen-return", meta.SiteUrl), ReturnUrl: fmt.Sprintf("%s/payment/adyen/return", meta.SiteUrl),
LineItems: lineItems, LineItems: lineItems,
}, nil }, nil

View File

@@ -4,14 +4,12 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"log" "log"
"net/http" "net/http"
"os" "os"
"time" "time"
"git.k6n.net/go-cart-actor/pkg/actor" "git.k6n.net/go-cart-actor/pkg/actor"
"git.k6n.net/go-cart-actor/pkg/cart"
"git.k6n.net/go-cart-actor/pkg/checkout" "git.k6n.net/go-cart-actor/pkg/checkout"
messages "git.k6n.net/go-cart-actor/proto/checkout" messages "git.k6n.net/go-cart-actor/proto/checkout"
@@ -170,6 +168,30 @@ func init() {
} }
} }
func (s *CheckoutPoolServer) applyAnywhere(ctx context.Context, id uint64, msgs ...proto.Message) error {
host, found := s.OwnerHost(id)
if !found {
_, err := s.Apply(ctx, id, msgs...)
return err
}
_, err := host.Apply(ctx, id, msgs...)
return err
}
func (s *CheckoutPoolServer) getAnywhere(ctx context.Context, id uint64) (*checkout.CheckoutGrain, error) {
host, found := s.OwnerHost(id)
if !found {
grain, err := s.Get(ctx, id)
return grain, err
}
ret := &checkout.CheckoutGrain{}
err := host.Get(ctx, id, ret)
if err != nil {
return nil, err
}
return ret, nil
}
func (s *CheckoutPoolServer) Serve(mux *http.ServeMux) { func (s *CheckoutPoolServer) Serve(mux *http.ServeMux) {
handleFunc := func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request)) { handleFunc := func(pattern string, handlerFunc func(http.ResponseWriter, *http.Request)) {
attr := attribute.String("http.route", pattern) attr := attribute.String("http.route", pattern)
@@ -190,6 +212,7 @@ func (s *CheckoutPoolServer) Serve(mux *http.ServeMux) {
//handleFunc("/payment/adyen/cancel", s.AdyenCancelHandler) //handleFunc("/payment/adyen/cancel", s.AdyenCancelHandler)
handleFunc("/payment/klarna/validate", s.KlarnaValidationHandler) handleFunc("/payment/klarna/validate", s.KlarnaValidationHandler)
handleFunc("/payment/klarna/push", s.KlarnaPushHandler)
handleFunc("/payment/klarna/notification", s.KlarnaNotificationHandler) handleFunc("/payment/klarna/notification", s.KlarnaNotificationHandler)
conn, err := amqp.Dial(amqpUrl) conn, err := amqp.Dial(amqpUrl)
@@ -204,34 +227,4 @@ func (s *CheckoutPoolServer) Serve(mux *http.ServeMux) {
handleFunc("GET /confirmation/{order_id}", s.KlarnaConfirmationHandler) handleFunc("GET /confirmation/{order_id}", s.KlarnaConfirmationHandler)
// handleFunc("GET /checkout", s.CheckoutHandler(func(order *CheckoutOrder, w http.ResponseWriter) error {
// w.Header().Set("Content-Type", "text/html; charset=utf-8")
// w.Header().Set("Permissions-Policy", "payment=(self \"https://js.stripe.com\" \"https://m.stripe.network\" \"https://js.playground.kustom.co\")")
// w.WriteHeader(http.StatusOK)
// _, err := fmt.Fprintf(w, tpl, order.HTMLSnippet)
// return err
// }))
handleFunc("GET /confirmation/{order_id}", func(w http.ResponseWriter, r *http.Request) {
orderId := r.PathValue("order_id")
order, err := s.klarnaClient.GetOrder(r.Context(), orderId)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}
// Apply ConfirmationViewed to checkout
checkoutId := checkout.CheckoutId(cart.MustNewCartId()) // Need to resolve from order
s.Apply(r.Context(), uint64(checkoutId), &messages.ConfirmationViewed{})
// Callback to cart
// cartId := cart.CartId(checkoutId) // Assuming same
// s.cartClient.ApplyMutation(cartId, &messages.OrderCreated{OrderId: order.ID, Status: order.Status})
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, tpl, order.HTMLSnippet)
})
} }

View File

@@ -396,9 +396,10 @@ spec:
server: 10.10.1.10 server: 10.10.1.10
serviceAccountName: default serviceAccountName: default
containers: containers:
- image: registry.k6n.net/go-checkout-actor-amd64:latest - image: registry.k6n.net/go-cart-actor:latest
name: checkout-actor-amd64 name: checkout-actor-amd64
imagePullPolicy: Always imagePullPolicy: Always
command: ["/go-checkout-actor"]
lifecycle: lifecycle:
preStop: preStop:
exec: exec: