Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
massenz committed Mar 9, 2023
2 parents 754434f + 04de5ca commit b25a0a6
Show file tree
Hide file tree
Showing 18 changed files with 724 additions and 583 deletions.
2 changes: 1 addition & 1 deletion .run/Run all tests.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<working_directory value="$PROJECT_DIR$" />
<parameters value="./api ./grpc ./pubsub ./storage" />
<kind value="DIRECTORY" />
<package value="github.com/massenz/go-statemachine" />
<package value="github.com/massenz/go-statemachine/api" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
Expand Down
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ GOOS ?= $(shell uname -s | tr "[:upper:]" "[:lower:]")
GOARCH ?= amd64
GOMOD := $(shell go list -m)

version := v0.10.0
version := v0.11.0
release := $(version)-g$(shell git rev-parse --short HEAD)
prog := sm-server
bin := out/bin/$(prog)-$(version)_$(GOOS)-$(GOARCH)
dockerbin := out/bin/$(prog)-$(version)_linux-amd64
healthcheck := out/bin/grpc-health_linux-amd64

image := massenz/statemachine
compose := docker/compose.yaml
Expand Down Expand Up @@ -60,15 +61,18 @@ fmt: ## Formats the Go source code using 'go fmt'
.PHONY: build test container cov clean fmt
$(bin): cmd/main.go $(srcs)
@mkdir -p $(shell dirname $(bin))
GOOS=$(GOOS); GOARCH=$(GOARCH); go build \
GOOS=$(GOOS) GOARCH=$(GOARCH) go build \
-ldflags "-X $(GOMOD)/api.Release=$(release)" \
-o $(bin) cmd/main.go

$(dockerbin):
GOOS=linux; GOARCH=amd64; go build \
$(dockerbin): $(srcs)
GOOS=linux GOARCH=amd64 go build \
-ldflags "-X $(GOMOD)/api.Release=$(release)" \
-o $(dockerbin) cmd/main.go

$(healthcheck): grpc_health.go
GOOS=linux GOARCH=amd64 go build -o $(healthcheck) grpc_health.go

.PHONY: build
build: $(bin) ## Builds the Statemachine server binary

Expand All @@ -83,8 +87,10 @@ cov: $(srcs) $(test_srcs) ## Runs the Test Coverage target and opens a browser
# Convenience targets to run locally containers and
# setup the test environments.

container: $(dockerbin) ## Builds the container image
docker build --build-arg appname=$(dockerbin) -f $(dockerfile) -t $(image):$(release) .
container: $(dockerbin) $(healthcheck) ## Builds the container image
docker build --build-arg appname=$(dockerbin) \
--build-arg hc=$(healthcheck) \
-f $(dockerfile) -t $(image):$(release) .

.PHONY: start
start: ## Starts the Redis and LocalStack containers, and Creates the SQS Queues in LocalStack
Expand Down
8 changes: 6 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@ LABEL org.opencontainers.image.description="Statemachine gRPC Server"
LABEL org.opencontainers.image.licenses=Apache-2.0

ARG appname
ARG hc

RUN apt-get update && apt-get install ca-certificates -y
RUN groupadd -r sm-bot && useradd -r -g sm-bot sm-bot
# Sensible defaults for the server, for reference
# we list all the environment variables used by the
# entrypoint script.
#
ENV GRPC_PORT=7398 SERVER_PORT=7399 DEBUG="" \
EVENTS_Q="events" NOTIFICATIONS_Q="notifications" \
ACKS_Q="" ERRORS_ONLY=t \
CLUSTER="" REDIS="redis:6379"
CLUSTER="" REDIS="redis:6379" \
TIMEOUT=500ms INSECURE=""

WORKDIR /app
RUN chown sm-bot:sm-bot /app

USER sm-bot
ADD $appname ./sm-server
ADD $hc ./ping
ADD docker/entrypoint.sh ./

EXPOSE ${SERVER_PORT}
ENTRYPOINT ["./entrypoint.sh"]
HEALTHCHECK --start-period=5s --interval=30s --timeout=200ms --retries=5 \
CMD ./ping -host localhost:$GRPC_PORT -timeout $TIMEOUT $INSECURE
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ then
retries="-max-retries ${RETRIES}"
fi

cmd="./sm-server -grpc-port ${GRPC_PORT} -redis ${REDIS:-} ${DEBUG:-}
cmd="./sm-server -grpc-port ${GRPC_PORT} -redis ${REDIS:-} ${DEBUG:-} ${INSECURE:-}
${endpoint} ${timeout} ${retries} ${events} ${notifications} $@"

echo $cmd
Expand Down
12 changes: 8 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ require (
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0
github.com/massenz/slf4go v0.3.2-g4eb5504
github.com/massenz/statemachine-proto/golang v1.1.0-beta-g1fc5dd8
github.com/massenz/statemachine-proto/golang v1.2.0-g8dbe9c5
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.18.1
github.com/stretchr/testify v1.8.2
github.com/testcontainers/testcontainers-go v0.18.0
google.golang.org/grpc v1.51.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.28.1
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/containerd v1.6.18 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v23.0.0+incompatible // indirect
Expand All @@ -43,11 +45,13 @@ require (
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit b25a0a6

Please sign in to comment.