Skip to content

Repository files navigation

docker-parse-server

Docker PullsDocker StarsDocker SizeDocker LayersDocker TagLicenseTravis CIGitter Chat

DeployDeploy to AzureDeploy to AWSDeploy to ScalingoDeploy to Docker CloudDeploy to Tutum

You should not build your parse-server image instead of reuse this yongjhih/parse-server image, then plugin your parse-cloud-code container (allow dynamic update) and mongodb container.

Welcome PR.

Here is overview:

Parse Server Diagram

Features:

  • Support latest parse-server npm version: yongjhih/parse-server:latest
  • Support various parse-server npm versions: yongjhih/parse-server:2.2.6
  • Support latest parse-server commit: yongjhih/parse-server:dev
  • Support docker stack with docker-compose
  • Support parse-cloud-code volume
  • Support parse-dashboard
  • Support mongodb
  • Support git deploy parse-cloud-code and auto effect after pushed
  • Tested docker image

Most pulled:

parse-server pulls

Getting Started

Screencast

Parse Dashboard Screenshot

$ docker run -d -p 27017:27017 --name mongo mongo
$ docker run -d \
-e APP_ID=${PARSE_APP_ID} \
-e MASTER_KEY=${PARSE_MASTER_KEY} \
-p 1337:1337 \
-p 2022:22 \
--link mongo \
--name parse-server \
yongjhih/parse-server
# Test parse-server
$ curl -X POST \
-H "X-Parse-Application-Id: {appId}" \
-H "Content-Type: application/json" \
-d '{}' \
http://localhost:1337/parse/functions/hello
$ docker run -d \
-e APP_ID=${PARSE_APP_ID} \
-e MASTER_KEY=${PARSE_MASTER_KEY} \
-p 4040:4040 \
--link parse-server \
--name parse-dashboard \
yongjhih/parse-dashboard
#The above command will asuume you will later create a ssh #and log into the dashboard remotely in production. # However, to see the dashboard instanly using either# localhost:4040 or someip:4040(if hosted somewhere remotely)#then you need to add extra option to allowInsecureHTTP like#It is also required that you create username and password #before accessing the portal else you cant get in
$ docker run -d \
-e APP_ID=$(PARSE_APP_ID)\
-e MASTER_KEY=$(PARSE_MASTER_KEY)\
-e PARSE_DASHBOARD_ALLOW_INSECURE_HTTP=1 \
-e USER1=yourUsername \
-e USER1_PASSWORD=yourUsernamesPassword \
-e PARSE_SERVER_URL=http://localhost:1337/parse \
-p 4040:4040 \
--link parse-server \
--name parse-dashboard \
yongjhih/parse-dashboard

or with docker-compose:

$ wget https://github.com/yongjhih/docker-parse-server/raw/master/docker-compose.yml
$ APP_ID=myAppId MASTER_KEY=myMasterKey docker-compose up -d

p.s. $ wget https://github.com/yongjhih/docker-parse-server/raw/master/docker-compose.yml -O - | APP_ID=myAppId MASTER_KEY=myMasterKey docker-compose up -d -f - # not supported for docker-compose container

Deploy parse-cloud-code via git:

Screencast - git

#This command wil create a SSH keys for you as# ~/.ssh/id_rsa.pub and another private key.#you can leave the options balnk by pressing enter.$ssh-keygen -t rsa
$ docker exec -i parse-server ssh-add-key <~/.ssh/id_rsa.pub
$ git clone ssh://git@localhost:2022/parse-cloud-code
$ cd parse-cloud-code
$ echo"Parse.Cloud.define('hello', function(req, res) { res.success('Hi, git'); });"> main.js
$ git add main.js && git commit -m 'Update main.js'
$ git push origin master
$ curl -X POST \
-H "X-Parse-Application-Id: ${PARSE_APP_ID}" \
-H "Content-Type: application/json" \
-d '{}' \
http://localhost:1337/parse/functions/hello
  • api: localhost:1337
  • git: localhost:2022
  • mongodb: localhost:27017

Usage of already mongodb with DATABASE_URI

$ docker run -d \
-e DATABASE_URI=${PARSE_DATABASE_URI:-mongodb://mongodb.intra:27017/dev} \
-e APP_ID=${PARSE_APP_ID} \
-e MASTER_KEY=${PARSE_MASTER_KEY} \
-p 1337:1337 \
-p 2022:22 \
--name parse-server \
yongjhih/parse-server

or with docker-compose:

$ wget https://github.com/yongjhih/docker-parse-server/raw/master/docker-compose.yml
$ DATABASE_URI={mongodb://mongodb.intra:27017/dev} APP_ID={appId} MASTER_KEY={masterKey} docker-compose up

Usage of already parse-cloud-code

With host folder:

$ docker run -d \
-v ${PARSE_CLOUD:-/home/yongjhih/parse/cloud}:/parse/cloud \
-e DATABASE_URI=${PARSE_DATABASE_URI:-mongodb://mongodb.intra:27017/dev} \
-e APP_ID={appId} \
-e MASTER_KEY={masterKey} \
-p 1337:1337 \
-p 2022:22 \
--link mongo \
--name parse-server \
yongjhih/parse-server

With volume container:

$ docker create --name parse-cloud-code \
-v /parse/cloud \
${DOCKER_PARSE_CLOUD:-yongjhih/parse-cloud-code}echo ls /parse/cloud
$ docker run -d \
--volumes-from parse-cloud-code \
-e DATABASE_URI=${PARSE_DATABASE_URI:-mongodb://mongodb.intra:27017/dev} \
-e APP_ID=${PARSE_APP_ID} \
-e MASTER_KEY=${PARSE_MASTER_KEY} \
-p 1337:1337 \
-p 2022:22 \
--link mongo \
--name parse-server \
yongjhih/parse-server

Usage of specific parse-server version

Specify parse-server:2.2.6:

$ docker run -d \
-e APP_ID=${PARSE_APP_ID} \
-e MASTER_KEY=${PARSE_MASTER_KEY} \
-p 1337:1337 \
-p 2022:22 \
--link mongo \
--name parse-server \
yongjhih/parse-server:2.2.6

ref. https://github.com/ParsePlatform/parse-server/releases ref. https://www.npmjs.com/package/parse-server

Usage of specific latest commit of ParsePlatform/parse-server of image

$ docker run -d \
-e APP_ID=${PARSE_APP_ID} \
-e MASTER_KEY=${PARSE_MASTER_KEY} \
-p 1337:1337 \
-p 2022:22 \
--link mongo \
--name parse-server \
yongjhih/parse-server:dev

Usage of standalone parse dashboard

Up parse-dashboard: https://github.com/yongjhih/docker-parse-dashboard

And, up other containers without parse-dashboard:

$ APP_ID=myAppId MASTER_KEY=myMasterKey docker-compose up -d -f docker-compose-without-dashboard.yml

Usage of letsencrypt for parse-dashboard with https certificated domain

$ git clone https://github.com/yongjhih/docker-parse-server
$ cd docker-parse-server
$ USER1=yongjhih \
USER1_PASSWORD=yongjhih \
LETSENCRYPT_EMAIL=yongjhih@example.com \
LETSENCRYPT_HOST=yongjhih.example.com \
VIRTUAL_HOST=yongjhih.example.com \
APP_ID=myAppId MASTER_KEY=myMasterKey docker-compose -f docker-compose-le.yml up

Open your https://yongjhih.example.com/ url and unblock browser protected scripts, that's it.

BTW, you can remove unused 80 port after volumes/proxy/certs generated:

sed -i -- '/- "80:80"/d' docker-compose-le.yml

Integration of parse-cloud-code image on GitHub and DockerHub

  1. Fork https://github.com/yongjhih/parse-cloud-code
  2. Add your cloud code into https://github.com/{username}/parse-cloud-code/tree/master/cloud
  3. Create an automated build image on DockerHub for forked {username}/parse-cloud-code repository
  4. docker pull {username}/parse-cloud-code

Without docker-compose:

  • Re/create parse-cloud-code volume container: docker create -v /parse/code --name parse-cloud-code {username}/parse-cloud-code /bin/true
  • Re/create parse-server container with volume: docker run -d --volumes-from parse-cloud-code APP_ID={appId} -e MASTER_KEY={masterKey} -p 1337:1337 -p 2022:22 --link mongo yongjhih/parse-server

With docker-compose.yml:

# ...parse-cloud-code:
# ...image: {username}/parse-cloud-code # Specify your parse-cloud-code image# ...
docker-compose up

Configuration with docker

  • Specify application ID: -e APP_ID={appId}
  • Specify master key: -e MASTER_KEY={masterKey}
  • Specify database uri: -e DATABASE_URI={mongodb://mongodb.intra:27017/dev}
  • Specify parse-server port on host: -p {1338}:1337
  • Specify parse-cloud-code git port on host: -p {2023}:22
  • Specify database port on host: -p {27018}:27017
  • Specify parse cloud code host folder: -v {/home/yongjhih/parse/cloud}:/parse/cloud
  • Specify parse cloud code volume container: --volumes-from {parse-cloud-code}
  • Specify parse-server prefix: -e PARSE_MOUNT={/parse}

Configuration with docker-compose.yml

Environment:

# ...parse-server:
# ...environment:
DATABASE_URI: $DATABASE_URIAPP_ID: $APP_IDMASTER_KEY: $MASTER_KEYPARSE_MOUNT: $PARSE_MOUNT # /parseCOLLECTION_PREFIX: $COLLECTION_PREFIXCLIENT_KEY: $CLIENT_KEYREST_API_KEY: $REST_API_KEYDOTNET_KEY: $DOTNET_KEYJAVASCRIPT_KEY: $JAVASCRIPT_KEYDOTNET_KEY: $DOTNET_KEYFILE_KEY: $FILE_KEYFACEBOOK_APP_IDS: $FACEBOOK_APP_IDSSERVER_URL: $SERVER_URLMAX_UPLOAD_SIZE: $MAX_UPLOAD_SIZE # 20mbGCM_ID: $GCM_IDGCM_KEY: $GCM_KEYPRODUCTION_PFX: $PRODUCTION_PFXPRODUCTION_BUNDLE_ID: $PRODUCTION_BUNDLE_IDPRODUCTION_CERT: $PRODUCTION_CERT # prodCert.pemPRODUCTION_KEY: $PRODUCTION_KEY # prodKey.pemDEV_PFX: $DEV_PFXDEV_BUNDLE_ID: $DEV_BUNDLE_IDDEV_CERT: $DEV_CERT # devCert.pemDEV_KEY: $DEV_KEY # devKey.pemVERIFY_USER_EMAILS: $VERIFY_USER_EMAILS # falseENABLE_ANON_USERS: $ENABLE_ANON_USERS # trueALLOW_CLIENT_CLASS_CREATION: $ALLOW_CLIENT_CLASS_CREATION # trueAPP_NAME: $APP_NAMEPUBLIC_SERVER_URL: $PUBLIC_SERVER_URLTRUST_PROXY: $TRUST_PROXY # false# ...

Remote parse-cloud-code image:

# ...parse-cloud-code:
# ...image: yongjhih/parse-cloud-code # Specify your parse-cloud-code image# ...

or host folder:

# ...parse-cloud-code:
# ...image: yongjhih/parse-servervolumes:
- /home/yongjhih/parse/cloud:/parse/cloud# ...# ...

Add ssh-key for git

$ docker exec -i parse-server ssh-add-key <~/.ssh/id_rsa.pub

Import keys from github:

$ curl https://github.com/yongjhih.keys | docker exec -i parse-server ssh-add-key

Deploy cloud code via git

$ git clone ssh://git@localhost:2022/parse-cloud-code
# ...
$ git push origin master

Getting Started With Cloud Services

Getting Started With Heroku + Mongolab Development

With the Heroku Button

Deploy

Without It

  • Clone the repo and change directory to it
  • Log in with the Heroku Toolbelt and create an app: heroku create
  • Use the MongoLab addon: heroku addons:create mongolab:sandbox
  • By default it will use a path of /parse for the API routes. To change this, or use older client SDKs, run heroku config:set PARSE_MOUNT=/1
  • Deploy it with: git push heroku master

Getting Started With AWS Elastic Beanstalk

With the Deploy to AWS Button

Without It

  • Clone the repo and change directory to it
  • Log in with the AWS Elastic Beanstalk CLI, select a region, and create an app: eb init
  • Create an environment and pass in MongoDB URI, App ID, and Master Key: eb create --envvars DATABASE_URI=<replace with URI>,APP_ID=<replace with Parse app ID>,MASTER_KEY=<replace with Parse master key>

Getting Started With Microsoft Azure App Service

With the Deploy to Azure Button

Deploy to Azure

Without It

A detailed tutorial is available here: Azure welcomes Parse developers

Getting Started With Google App Engine

  1. Clone the repo and change directory to it
  2. Create a project in the Google Cloud Platform Console.
  3. Enable billing for your project.
  4. Install the Google Cloud SDK.
  5. Setup a MongoDB server. You have a few options:
  6. Create a Google Compute Engine virtual machine with MongoDB pre-installed.
  7. Use MongoLab to create a free MongoDB deployment on Google Cloud Platform.
  8. Modify app.yaml to update your environment variables.
  9. Delete Dockerfile
  10. Deploy it with gcloud preview app deploy

A detailed tutorial is available here: Running Parse server on Google App Engine

Getting Started With Scalingo

With the Scalingo button

Deploy to Scalingo

Without it

  • Clone the repo and change directory to it
  • Log in with the Scalingo CLI and create an app: scalingo create my-parse
  • Use the Scalingo MongoDB addon: scalingo addons-add scalingo-mongodb free
  • Setup MongoDB connection string: scalingo env-set DATABASE_URI='$SCALINGO_MONGO_URL'
  • By default it will use a path of /parse for the API routes. To change this, or use older client SDKs, run scalingo env-set PARSE_MOUNT=/1
  • Deploy it with: git push scalingo master

Using it

You can use the REST API, the JavaScript SDK, and any of our open-source SDKs:

Example request to a server running locally:

curl -X POST \
-H "X-Parse-Application-Id: myAppId" \
-H "Content-Type: application/json" \
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
http://localhost:1337/parse/classes/GameScore
curl -X POST \
-H "X-Parse-Application-Id: myAppId" \
-H "Content-Type: application/json" \
-d '{}' \
http://localhost:1337/parse/functions/hello

Example using it via JavaScript:

Parse.initialize('myAppId','unused');
Parse.serverURL = 'https://whatever.herokuapp.com';
var obj = new Parse.Object('GameScore');
obj.set('score',1337);
obj.save().then(function(obj) {
console.log(obj.toJSON());
var query = new Parse.Query('GameScore');
query.get(obj.id).then(function(objAgain) {
console.log(objAgain.toJSON());
}, function(err) {console.log(err); });
}, function(err) { console.log(err); });

Example using it on Android:

//in your application class
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
.applicationId("myAppId")
.clientKey("myClientKey")
.server("http://myServerUrl/parse/") // '/' important after 'parse'
.build());
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();

You can change the server URL in all of the open-source SDKs, but we're releasing new builds which provide initialization time configuration of this property.

See Also

About

Provide docker images and docker stack for parse-server npm versions and latest commit

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages