-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cardinal version bump, better docker cache
- Loading branch information
Showing
6 changed files
with
288 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,61 @@ | ||
# Base Builder Stage | ||
FROM golang:1.22 AS builder | ||
################################ | ||
# Build Image - Normal | ||
################################ | ||
FROM golang:1.22-bookworm AS build | ||
|
||
RUN go install github.com/go-delve/delve/cmd/dlv@latest | ||
WORKDIR /go/src/app | ||
|
||
WORKDIR /usr/src/app | ||
COPY . . | ||
# 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 | ||
|
||
RUN go build -v -o /usr/local/bin/app | ||
RUN go build -gcflags="all=-N -l" -v -o /usr/local/bin/app-debug | ||
# Set the GOCACHE environment variable to /root/.cache/go-build to speed up build | ||
ENV GOCACHE=/root/.cache/go-build | ||
|
||
# Runtime Debug Stage | ||
FROM ubuntu:22.04 AS runtime-debug | ||
# 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 | ||
|
||
COPY --from=builder /go/bin/dlv /usr/local/bin | ||
COPY --from=builder /usr/local/bin/app-debug /usr/local/bin/ | ||
################################ | ||
# Runtime Image - Normal | ||
################################ | ||
FROM gcr.io/distroless/base-debian12 AS runtime | ||
|
||
CMD ["dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/usr/local/bin/app-debug"] | ||
# 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 | ||
|
||
# Runtime Stage | ||
FROM ubuntu:22.04 AS runtime | ||
# Run the binary | ||
CMD ["app"] | ||
|
||
COPY --from=builder /usr/local/bin/app /usr/local/bin/ | ||
################################ | ||
# Runtime Image - Debug | ||
################################ | ||
FROM golang:1.22-bookworm AS runtime-debug | ||
|
||
CMD ["app"] | ||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.