Skip to content

Commit

Permalink
feat: cardinal version bump, better docker cache
Browse files Browse the repository at this point in the history
  • Loading branch information
smsunarto committed Jun 24, 2024
1 parent 8440c5b commit 2346bdf
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 251 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ jobs:
build-cardinal:
name: Cardinal
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cardinal
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
uses: golangci/golangci-lint-action@v4
with:
version: v1.56.2
args: --timeout=10m -v
args: --timeout=10m
working-directory: ./cardinal
27 changes: 0 additions & 27 deletions .github/workflows/lint-md.yml

This file was deleted.

61 changes: 61 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
################################
# Build Image - Normal
################################
FROM golang:1.22-bookworm AS build

WORKDIR /go/src/app

# Copy the go module files and download the dependencies
# We do this before copying the rest of the source code to avoid
# having to re-download the dependencies every time we build the image
COPY /cardinal/go.mod /cardinal/go.sum ./
RUN go mod download

# Set the GOCACHE environment variable to /root/.cache/go-build to speed up build
ENV GOCACHE=/root/.cache/go-build

# Copy the rest of the source code and build the binary
COPY /cardinal ./
RUN --mount=type=cache,target="/root/.cache/go-build" go build -v -o /go/bin/app

################################
# Runtime Image - Normal
################################
FROM gcr.io/distroless/base-debian12 AS runtime

# Copy world.toml to the image
COPY world.toml world.toml

# Copy the binary from the build image
COPY --from=build /go/bin/app /usr/bin

# Run the binary
CMD ["app"]

################################
# Runtime Image - Debug
################################
FROM golang:1.22-bookworm AS runtime-debug

WORKDIR /go/src/app

# Install delve
RUN go install github.com/go-delve/delve/cmd/dlv@latest

# Copy the go module files and download the dependencies
# We do this before copying the rest of the source code to avoid
# having to re-download the dependencies every time we build the image
COPY /cardinal/go.mod /cardinal/go.sum ./
RUN go mod download

# Set the GOCACHE environment variable to /root/.cache/go-build to speed up build
ENV GOCACHE=/root/.cache/go-build

# Copy the rest of the source code and build the binary with debugging symbols
COPY /cardinal ./
RUN --mount=type=cache,target="/root/.cache/go-build" go build -gcflags="all=-N -l" -v -o /usr/bin/app

# Copy world.toml to the image
COPY world.toml world.toml

CMD ["dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/usr/bin/app"]
6 changes: 6 additions & 0 deletions cardinal/.run/Cardinal - Debug.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Cardinal - Debug" type="GoRemoteDebugConfigurationType" factoryName="Go Remote" port="40000">
<option name="disconnectOption" value="ASK" />
<method v="2" />
</configuration>
</component>
26 changes: 0 additions & 26 deletions cardinal/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions cardinal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ lint-install:
lint:
@$(MAKE) lint-install
@echo "--> Running golangci-lint"
@golangci-lint run --timeout=10m --concurrency 8 -v
@golangci-lint run --timeout=10m


# Run golangci-lint on the project and fix any issues
lint-fix:
@$(MAKE) lint-install
@echo "--> Running golangci-lint"
@golangci-lint run --timeout=10m --fix --concurrency 8 -v
@golangci-lint run --timeout=10m --fix

test:
@go test ./...
55 changes: 38 additions & 17 deletions cardinal/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ go 1.22.1
require (
github.com/rs/zerolog v1.32.0
gotest.tools/v3 v3.5.1
pkg.world.dev/world-engine/cardinal v1.3.3
pkg.world.dev/world-engine/cardinal v1.4.1
)

require (
github.com/DataDog/appsec-internal-go v1.0.2 // indirect
github.com/DataDog/appsec-internal-go v1.5.0 // indirect
github.com/DataDog/datadog-agent/pkg/obfuscate v0.48.0 // indirect
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.48.1 // indirect
github.com/DataDog/datadog-go/v5 v5.4.0 // indirect
github.com/DataDog/go-libddwaf/v2 v2.1.0 // indirect
github.com/DataDog/go-libddwaf/v2 v2.4.2 // indirect
github.com/DataDog/go-tuf v1.0.2-0.5.2 // indirect
github.com/DataDog/gostackparse v0.7.0 // indirect
github.com/DataDog/sketches-go v1.4.2 // indirect
github.com/JeremyLoy/config v1.5.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/alecthomas/participle/v2 v2.1.0 // indirect
Expand All @@ -28,9 +28,12 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ebitengine/purego v0.5.0 // indirect
github.com/ethereum/go-ethereum v1.13.4 // indirect
github.com/ebitengine/purego v0.6.0-alpha.5 // indirect
github.com/ethereum/go-ethereum v1.13.10 // indirect
github.com/fasthttp/websocket v1.5.8 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
Expand All @@ -40,29 +43,44 @@ require (
github.com/gofiber/contrib/websocket v1.3.0 // indirect
github.com/gofiber/fiber/v2 v2.52.2 // indirect
github.com/gofiber/swagger v0.1.14 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20230901174712-0191c66da455 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/holiman/uint256 v1.2.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect
github.com/invopop/jsonschema v0.7.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/outcaste-io/ristretto v0.2.3 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/redis/go-redis/v9 v9.1.0 // indirect
github.com/richardartoul/molecule v1.0.1-0.20221107223329-32cfee06a052 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rotisserie/eris v0.5.4 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/savsgio/gotils v0.0.0-20240303185622-093b76447511 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/swaggo/swag v1.16.3 // indirect
github.com/tidwall/gjson v1.17.0 // indirect
Expand All @@ -75,23 +93,26 @@ require (
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/wI2L/jsondiff v0.5.0 // indirect
github.com/yuin/gopher-lua v1.1.0 // indirect
go.opentelemetry.io/otel v1.26.0 // indirect
go.opentelemetry.io/otel/metric v1.26.0 // indirect
go.opentelemetry.io/otel/trace v1.26.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go4.org/intern v0.0.0-20230525184215-6c62f75575cb // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.16.1 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/DataDog/dd-trace-go.v1 v1.58.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/DataDog/dd-trace-go.v1 v1.63.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a // indirect
pkg.world.dev/world-engine/rift v1.1.0-beta.0.20240402214846-de1fc179818a // indirect
pkg.world.dev/world-engine/sign v1.0.1-beta // indirect
)
Loading

0 comments on commit 2346bdf

Please sign in to comment.