Skip to content

totoroot/code-push-server-go

 
 

Repository files navigation

code-push-server-go

Codepush server go is compatible with react-native-code-push. Need to be used with code-push-go. Only supported react-native

Support version

Support client version

Support storage

  • Local
  • AWS S3
  • GCP Bucket (Google Cloud Storage)
  • FTP

GCS access permissions

A service account token with the IAM permission "Storage Object User" is needed to access the Google Cloud Storage bucket.

The service account token has to be exported and the path to the JSON file has to be provided via the config file.

Before installation, please ensure that the following procedures have been installed

  • mysql
  • golang
  • redis

Install code-push-server

git clone https://github.com/htdcx/code-push-server-go.git
cd code-push-server-go
import code-push.sql to mysql

Configuration mysql,redis,storage

cd config
vi (app.json or app.dev.json or app.prod.json)
# app.json
{
    "mode":"prod" #run read config app.{mode}.json
}
# app.prod.json
{
    "DBUser": {
        "Write": {
            "UserName": "",
            "Password": "",
            "Host": "127.0.0.1",
            "Port": 3306,
            "DBname": ""
        },
        "MaxIdleConns": 10,
        "MaxOpenConns": 100,
        "ConnMaxLifetime": 1
    },
    "Redis": {
        "Host": "127.0.0.1",
        "Port": 6379,
        "DBIndex": 0,
        "UserName": "",
        "Password": ""
    },
    "CodePush": {
        "FileLocal":(local,aws,gcp,ftp),
        "Local":{
            "SavePath":"./bundles"
        },
        "Aws":{
            "Endpoint":"",
            "Region":"",
            "S3ForcePathStyle":true,
            "KeyId":"",
            "Secret":"",
            "Bucket":""
        },
        "Gcp":{
            "Bucket":"",
            "Object":"",
            "ServiceAccountJSON": ""
        },
        "Ftp":{
            "ServerUrl":"",
            "UserName":"",
            "Password":""
        }
    },
    "UrlPrefix": "/",
    "ResourceUrl": (nginx config url or s3),
    "Port": ":8080",
    "TokenExpireTime": 30 (day)
}

Build

# MacOS pack GOOS:windows,darwin
CGO_ENABLED=0 GOOS=linux  GOARCH=amd64 go build -o code-push-server-go(.exe) main.go

# Windows pack
set GOARCH=amd64
set GOOS=linux #windows,darwin
go build -o code-push-server-go(.exe) main.go

# Copy config/app.(model).json and config/app.json to run dir

# Linux server
chmod +x code-push-server-go

# Run
./code-push-server-go

Default user name and password

  • Username:admin
  • Password:admin

Change password and user name

 Version >= 1.0.5 :./code-push-go change_password
 Version <= 1.0.4 :Change mysql users tables (password need md5)
./code-push-go login -u (userName) -p (password) -h (serverUrl)

Configuration client react-native-code-push

# iOS add to Info.plist
<key>CodePushServerURL</key>
<string>${CODE_PUSH_SERVER_URL}</string>

# Android add to res/value/strings.xml
<string moduleConfig="true" name="CodePushServerUrl">${CODE_PUSH_SERVER_URL}</string>

License

MIT License Read

About

Server that supports react-native-code-push

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%