Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ app-cla-server
commentsRouter_controllers.go
lastupdate.tmp
conf/*
.idea
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:latest as BUILDER

MAINTAINER TommyLike<[email protected]>

# 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"]
29 changes: 29 additions & 0 deletions deploy/app.conf
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
21 changes: 12 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"os"

"github.com/astaxie/beego"

platformAuth "github.com/opensourceways/app-cla-server/code-platform-auth"
Expand All @@ -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(
Expand All @@ -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())
Expand Down