Skip to content

Commit

Permalink
Merge pull request #5 from AAStarCommunity/chao/e2e-phase-1
Browse files Browse the repository at this point in the history
test: add dockerfile
  • Loading branch information
fanhousanbu authored Apr 25, 2024
2 parents 633d38a + 20d22a8 commit 208caa0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## build
FROM golang:1.22.1-alpine3.19 AS build-env

RUN apk add build-base

ADD . /go/src/app

WORKDIR /go/src/app

RUN go env -w GO111MODULE=on \
&& go mod tidy \
&& go build -o cnode

## run
FROM alpine:3.19

RUN mkdir -p /aa && mkdir -p /aa/log

WORKDIR /aa

COPY --from=build-env /go/src/app /aa/

ENV PATH $PATH:/aa

EXPOSE 80
CMD ["/aa/cnode"]
4 changes: 2 additions & 2 deletions conf/appsettings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jwt:
node:
genesis: true
globalName: genesis-01
externalAddr: 0.0.0.0
externalAddr: "0.0.0.0"
externalPort: 7946
bindAddr: 0.0.0.0
bindAddr: "0.0.0.0"
bindPort: 7946
14 changes: 5 additions & 9 deletions conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,13 @@ func getConfiguration(filePath *string) *Conf {
return mappingEnvToConf(nil)
} else {
c := Conf{}
err := yaml.Unmarshal(file, &c)
if err != nil {
return mappingEnvToConf(&c)
}

return &c
yaml.Unmarshal(file, &c)
return mappingEnvToConf(&c)
}
}

func mappingEnvToConf(fileConf *Conf) *Conf {
envConf := &Conf{
func mappingEnvToConf(fileConf *Conf) (envConf *Conf) {
envConf = &Conf{
Web: Web{},
Db: DB{},
Jwt: JWT{},
Expand Down Expand Up @@ -150,5 +146,5 @@ func mappingEnvToConf(fileConf *Conf) *Conf {
}
}

return envConf
return
}
13 changes: 8 additions & 5 deletions conf/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

type Node struct {
Genesis bool
ExternalAddr string
ExternalPort int
BindAddr string
BindPort int
GlobalName string
ExternalAddr string `yaml:"externalAddr"`
ExternalPort int `yaml:"externalPort"`
BindAddr string `yaml:"bindAddr"`
BindPort int `yaml:"bindPort"`
GlobalName string `yaml:"globalName"`
}

var node *Node
Expand All @@ -27,6 +27,9 @@ func GetNode() *Node {
node = &Node{
Genesis: j.Genesis,
ExternalAddr: j.ExternalAddr,
ExternalPort: j.ExternalPort,
BindAddr: j.BindAddr,
BindPort: j.BindPort,
GlobalName: func() string {
if j.GlobalName == "" {
return fmt.Sprintf("aa:%s", uuid.NewString())
Expand Down
2 changes: 1 addition & 1 deletion internal/community/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func BindAccount(hashedAccount string, publicKey *string) error {
PublicKey: *publicKey,
RpcAddress: rpcAddress,
RpcPort: rpcPort,
Version: *&version,
Version: version,
})
}
}

0 comments on commit 208caa0

Please sign in to comment.