Skip to content

Commit

Permalink
k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
wikylyu committed Dec 26, 2024
1 parent 04f3c99 commit 806dbe5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WORKDIR $SERVER_DIR
# Copy all files from the current directory into the container
COPY . .

ENV HTTPS_PROXY=http://192.168.18.100:1081
RUN go mod download

# Install Mage to use for building the application
Expand All @@ -21,6 +22,9 @@ RUN go install github.com/magefile/[email protected]
# Optionally build your application if needed
RUN mage build

ENV HTTPS_PROXY=


# Using Alpine Linux with Go environment for the final image
FROM golang:1.22-alpine

Expand All @@ -43,7 +47,10 @@ COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/

ENV HTTPS_PROXY=http://192.168.18.100:1081

RUN go get github.com/openimsdk/[email protected]
ENV HTTPS_PROXY=

# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]
6 changes: 3 additions & 3 deletions internal/push/onlinepusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (u emptyOnlinePusher) GetOnlinePushFailedUserIDs(ctx context.Context, msg *

func NewOnlinePusher(disCov discovery.SvcDiscoveryRegistry, config *Config) OnlinePusher {

if config.runTimeEnv == conf.KUBERNETES {
return NewDefaultAllNode(disCov, config)
}
// if config.runTimeEnv == conf.KUBERNETES {
// return NewDefaultAllNode(disCov, config)
// }
switch config.Discovery.Enable {
case conf.ETCD:
return NewDefaultAllNode(disCov, config)
Expand Down
17 changes: 8 additions & 9 deletions pkg/common/config/load_config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package config

import (
"os"
"path/filepath"
"strings"

Expand All @@ -11,14 +10,14 @@ import (
)

func Load(configDirectory string, configFileName string, envPrefix string, runtimeEnv string, config any) error {
if runtimeEnv == KUBERNETES {
mountPath := os.Getenv(MountConfigFilePath)
if mountPath == "" {
return errs.ErrArgs.WrapMsg(MountConfigFilePath + " env is empty")
}

return loadConfig(filepath.Join(mountPath, configFileName), envPrefix, config)
}
// if runtimeEnv == KUBERNETES {
// mountPath := os.Getenv(MountConfigFilePath)
// if mountPath == "" {
// return errs.ErrArgs.WrapMsg(MountConfigFilePath + " env is empty")
// }

// return loadConfig(filepath.Join(mountPath, configFileName), envPrefix, config)
// }

return loadConfig(filepath.Join(configDirectory, configFileName), envPrefix, config)
}
Expand Down
17 changes: 7 additions & 10 deletions pkg/common/discoveryregister/discoveryregister.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,20 @@ import (

"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/tools/discovery"
"google.golang.org/grpc"

"github.com/openimsdk/tools/discovery/kubernetes"

"github.com/openimsdk/tools/discovery/etcd"
"github.com/openimsdk/tools/errs"
)

// NewDiscoveryRegister creates a new service discovery and registry client based on the provided environment type.
func NewDiscoveryRegister(discovery *config.Discovery, runtimeEnv string) (discovery.SvcDiscoveryRegistry, error) {
if runtimeEnv == config.KUBERNETES {
return kubernetes.NewKubernetesConnManager(discovery.Kubernetes.Namespace,
grpc.WithDefaultCallOptions(
grpc.MaxCallSendMsgSize(1024*1024*20),
),
)
}
// if runtimeEnv == config.KUBERNETES {
// return kubernetes.NewKubernetesConnManager(discovery.Kubernetes.Namespace,
// grpc.WithDefaultCallOptions(
// grpc.MaxCallSendMsgSize(1024*1024*20),
// ),
// )
// }

switch discovery.Enable {
case config.ETCD:
Expand Down
7 changes: 3 additions & 4 deletions tools/seq/internal/seq.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
"github.com/openimsdk/tools/db/mongoutil"
"github.com/openimsdk/tools/db/redisutil"
"github.com/openimsdk/tools/utils/runtimeenv"
"github.com/redis/go-redis/v9"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
Expand All @@ -43,9 +42,9 @@ const (
)

func readConfig[T any](dir string, name string) (*T, error) {
if runtimeenv.PrintRuntimeEnvironment() == config.KUBERNETES {
dir = os.Getenv(config.MountConfigFilePath)
}
// if runtimeenv.PrintRuntimeEnvironment() == config.KUBERNETES {
// dir = os.Getenv(config.MountConfigFilePath)
// }

data, err := os.ReadFile(filepath.Join(dir, name))
if err != nil {
Expand Down

0 comments on commit 806dbe5

Please sign in to comment.