├── Dockerfile ├── LICENSE ├── README.md ├── cloud └── main.js ├── package.json ├── parse.js └── supervisord.conf /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:argon 2 | MAINTAINER felix@felixrieseberg.com 3 | 4 | RUN mkdir -p /usr/src/parse 5 | WORKDIR /usr/src/parse 6 | 7 | # Install MongoDB 8 | RUN apt-get update \ 9 | && apt-get -y install mongodb 10 | 11 | RUN apt-get -y install supervisor 12 | COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf 13 | 14 | COPY package.json /usr/src/parse/ 15 | RUN npm install 16 | 17 | COPY . /usr/src/parse 18 | 19 | ENV APP_ID YourAppId 20 | ENV MASTER_KEY YourMasterKey 21 | ENV FILE_KEY YourOptionalFileKey 22 | 23 | EXPOSE 8080 27017 24 | 25 | CMD ["/usr/bin/supervisord"] 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Felix Rieseberg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Parse-Docker 2 | :speedboat: Run the Open Source Parse Server in Docker. This Docker Image will combine a simple Express Server (with the Parse Express Router Module) and a MongoDB server into a little Pares alternative. 3 | 4 | For this image to be useful, you probably want to override/change `cloud/main.js` - it is supposed to hold your Parse Cloud Code. Right now, it just contains some example code taken straight from Facebook's example. 5 | 6 | ## Variables 7 | The container and the Express server accept three environment variables: 8 | 9 | * `APP_ID` 10 | * `MASTER_KEY` 11 | * `FILE_KEY` 12 | 13 | ## Running 14 | ``` 15 | docker run felixrieseberg/docker-parse 16 | ``` 17 | 18 | To override the environment variables, specify them in your run command: 19 | ``` 20 | docker run -d -t -i -e APP_ID='my-app-id' -e MASTER_KEY='my-master-key' -e FILE_KEY='mt-file-key' -p 8080:8080 felixrieseberg/docker-parse 21 | ``` 22 | 23 | ## License 24 | MIT, please see `LICENSE` for details. 25 | -------------------------------------------------------------------------------- /cloud/main.js: -------------------------------------------------------------------------------- 1 | Parse.Cloud.define('hello', function(req, res) { 2 | res.success('Hello world!'); 3 | }); 4 | 5 | Parse.Cloud.beforeSave('BeforeSaveFailure', function(req, res) { 6 | res.error('You shall not pass!'); 7 | }); 8 | 9 | Parse.Cloud.beforeSave('BeforeSaveUnchanged', function(req, res) { 10 | res.success(); 11 | }); 12 | 13 | Parse.Cloud.beforeSave('BeforeSaveChanged', function(req, res) { 14 | req.object.set('foo', 'baz'); 15 | res.success(); 16 | }); 17 | 18 | Parse.Cloud.afterSave('AfterSaveTest', function(req) { 19 | var obj = new Parse.Object('AfterSaveProof'); 20 | obj.set('proof', req.object.id); 21 | obj.save(); 22 | }); 23 | 24 | Parse.Cloud.beforeDelete('BeforeDeleteFail', function(req, res) { 25 | res.error('Nope'); 26 | }); 27 | 28 | Parse.Cloud.beforeDelete('BeforeDeleteTest', function(req, res) { 29 | res.success(); 30 | }); 31 | 32 | Parse.Cloud.afterDelete('AfterDeleteTest', function(req) { 33 | var obj = new Parse.Object('AfterDeleteProof'); 34 | obj.set('proof', req.object.id); 35 | obj.save(); 36 | }); 37 | 38 | Parse.Cloud.beforeSave('SaveTriggerUser', function(req, res) { 39 | if (req.user && req.user.id) { 40 | res.success(); 41 | } else { 42 | res.error('No user present on request object for beforeSave.'); 43 | } 44 | }); 45 | 46 | Parse.Cloud.afterSave('SaveTriggerUser', function(req) { 47 | if (!req.user || !req.user.id) { 48 | console.log('No user present on request object for afterSave.'); 49 | } 50 | }); 51 | 52 | Parse.Cloud.define('foo', function(req, res) { 53 | res.success({ 54 | object: { 55 | __type: 'Object', 56 | className: 'Foo', 57 | objectId: '123', 58 | x: 2, 59 | relation: { 60 | __type: 'Object', 61 | className: 'Bar', 62 | objectId: '234', 63 | x: 3 64 | } 65 | }, 66 | array: [{ 67 | __type: 'Object', 68 | className: 'Bar', 69 | objectId: '345', 70 | x: 2 71 | }], 72 | a: 2 73 | }); 74 | }); 75 | 76 | Parse.Cloud.define('bar', function(req, res) { 77 | res.error('baz'); 78 | }); 79 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parse-docker-server", 3 | "version": "0.1.0", 4 | "description": "Parse Server on Docker", 5 | "main": "server.js", 6 | "scripts": { 7 | "start": "node parse.js" 8 | }, 9 | "dependencies": { 10 | "parse-server" : "2.2.4", 11 | "express": "^4.13.3", 12 | "parse": "~1.6.12" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /parse.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const ParseServer = require('parse-server').ParseServer; 3 | 4 | const app = express(); 5 | const port = process.env.PORT || 8080; 6 | 7 | // Specify the connection string for your mongodb database 8 | // and the location to your Parse cloud code 9 | const parse = new ParseServer({ 10 | databaseURI: 'mongodb://localhost:27017/dev', 11 | cloud: '/usr/src/parse/cloud/main.js', 12 | appId: process.env.APP_ID, 13 | masterKey: process.env.MASTER_KEY, 14 | fileKey: process.env.FILE_KEY, 15 | serverURL: 'http://localhost:1337/parse' 16 | }); 17 | 18 | // Serve the Parse API on the /parse URL prefix 19 | app.use('/parse', parse); 20 | 21 | // Hello world 22 | app.get('/', (req, res) => { 23 | res.status(200).send('Express is running here.'); 24 | }); 25 | 26 | app.listen(port, () => { 27 | console.log(`Docker Parse Server running on port ${port} with appId ${process.env.APP_ID}`); 28 | }); 29 | -------------------------------------------------------------------------------- /supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:mongodb] 5 | command=/usr/bin/mongod --config /etc/mongodb.conf 6 | 7 | [program:parse] 8 | command=npm start 9 | --------------------------------------------------------------------------------