diff --git a/.gitignore b/.gitignore index 6c15f24..57cdcaa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ app-cla-server commentsRouter_controllers.go lastupdate.tmp conf/* +.idea diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..673d54c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:latest as BUILDER + +MAINTAINER TommyLike + +# build binary +COPY . /go/src/github.com/opensourceways/app-cla-server +RUN cd /go/src/github.com/opensourceways/app-cla-server && CGO_ENABLED=1 go build -v -o ./cla-server main.go + +# copy binary config and utils +FROM golang:latest +RUN apt-get update && apt-get install -y python-pip && mkdir -p /opt/app/ +COPY ./conf /opt/app/conf +COPY ./util/merge-signature.py /opt/app/util +# overwrite config yaml +COPY ./deploy/app.conf /opt/app/conf +COPY --from=BUILDER /go/src/github.com/opensourceways/app-cla-server/cla-server /opt/app + +WORKDIR /opt/app/ +ENTRYPOINT ["/opt/app/cla-server"] diff --git a/deploy/app.conf b/deploy/app.conf new file mode 100644 index 0000000..81c0378 --- /dev/null +++ b/deploy/app.conf @@ -0,0 +1,29 @@ +appname = app-cla-server +httpport = "${HTTP_PORT||8080}" +runmode = "${RUN_MODE||prod}" +autorender = false +copyrequestbody = true +EnableDocs = false + +python_bin = /usr/bin/python + +mongodb_conn = "$MONGODB_CONNECTION" +mongodb_db = cla + +verification_vode_expiry = 300 +api_token_expiry = 300 +api_token_key = "$API_TOKEN_KEY" + +pdf_org_signature_dir = ./conf/pdfs/org_signature_pdf +pdf_out_dir = ./conf/pdfs/output + +code_platforms = ./conf/platforms/code_platforms.yaml +email_platforms = ./conf/platforms/email.yaml + +[blank_signature] +language = english +pdf = ./conf/blank_signature/english_blank_signature.pdf + +[pdf_template_corporation] +welcome = ./conf/pdf_template_corporation/welcome.tmpl +declaration = ./conf/pdf_template_corporation/declaration.tmpl diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1554c3a --- /dev/null +++ b/go.mod @@ -0,0 +1,16 @@ +module github.com/opensourceways/app-cla-server + +go 1.13 + +require ( + gitee.com/openeuler/go-gitee v0.0.0-20200506042249-a91b6e6ed1b1 + github.com/antihax/optional v1.0.0 + github.com/astaxie/beego v1.12.2 + github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/huaweicloud/golangsdk v0.0.0-20200907093635-5934c79d40de + github.com/jung-kurt/gofpdf v1.16.2 + go.mongodb.org/mongo-driver v1.4.1 + golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 + google.golang.org/api v0.31.0 + sigs.k8s.io/yaml v1.2.0 +) \ No newline at end of file diff --git a/main.go b/main.go index 507fb7d..60aa1e6 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,8 @@ package main import ( + "os" + "github.com/astaxie/beego" platformAuth "github.com/opensourceways/app-cla-server/code-platform-auth" @@ -22,27 +24,28 @@ func main() { beego.AppConfig.String("mongodb_conn"), beego.AppConfig.String("mongodb_db")) if err != nil { - return + beego.Error(err) + os.Exit(1) } dbmodels.RegisterDB(c) path := beego.AppConfig.String("email_platforms") if err = email.RegisterPlatform(path); err != nil { - beego.Info(err) - return + beego.Error(err) + os.Exit(1) } path = beego.AppConfig.String("code_platforms") if err := platformAuth.RegisterPlatform(path); err != nil { - beego.Info(err) - return + beego.Error(err) + os.Exit(1) } language := beego.AppConfig.String("blank_signature::language") path = beego.AppConfig.String("blank_signature::pdf") if err := pdf.UploadBlankSignature(language, path); err != nil { - beego.Info(err) - return + beego.Error(err) + os.Exit(1) } if err := pdf.InitPDFGenerator( @@ -52,8 +55,8 @@ func main() { beego.AppConfig.String("pdf_template_corporation::welcome"), beego.AppConfig.String("pdf_template_corporation::declaration"), ); err != nil { - beego.Info(err) - return + beego.Error(err) + os.Exit(1) } worker.InitEmailWorker(pdf.GetPDFGenerator())