├── shell_server.sh ├── .env.production ├── bootstrap.sh ├── docker.sh ├── setupServer.sh ├── docker.conf ├── deploy_openstack.sh ├── run_docker.sh ├── Dockerfile ├── README.md └── LICENSE /shell_server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker exec -i -t maproulette2 bash -------------------------------------------------------------------------------- /.env.production: -------------------------------------------------------------------------------- 1 | REACT_APP_BASE_PATH='/mr3' 2 | REACT_APP_URL='http://localhost/mr3' 3 | REACT_APP_MAP_ROULETTE_SERVER_URL='http://localhost' -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "bootstrap" 4 | 5 | service ssh restart 6 | 7 | cd /maproulettev2-1.0 8 | 9 | ./setupServer.sh > setupServer.log 2>&1 10 | 11 | while true; do sleep 1000; done -------------------------------------------------------------------------------- /docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker-machine create --driver virtualbox default 3 | status=$(docker-machine status default) 4 | if [ "$status" != "Running" ]; then 5 | docker-machine start default 6 | fi 7 | docker-machine env default 8 | eval "$(docker-machine env default)" 9 | 10 | export wipe_db=false 11 | ./run_docker.sh -------------------------------------------------------------------------------- /setupServer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # If you don't set 3 | if [ -z "$MAPROULETTE_DB_URL" ]; then 4 | MAPROULETTE_DB_URL="CHANGE_ME" 5 | fi 6 | if [ -z "$MAPROULETTE_CONSUMER_KEY" ]; then 7 | MAPROULETTE_CONSUMER_KEY="CHANGE_ME" 8 | fi 9 | if [ -z "$MAPROULETTE_CONSUMER_SECRET" ]; then 10 | MAPROULETTE_CONSUMER_SECRET="CHANGE_ME" 11 | fi 12 | port=$1 13 | if [ -z "$port" ]; then 14 | port="80" 15 | fi 16 | 17 | /MapRouletteV2/bin/maproulettev2 -Dhttp.port=$port -Dconfig.resource=docker.conf \ 18 | -DAPI_HOST='maproulette.org' \ 19 | -DMR_DATABASE_URL=$MAPROULETTE_DB_URL \ 20 | -DMR_CONSUMER_KEY=$MAPROULETTE_CONSUMER_KEY \ 21 | -DMR_CONSUMER_SECRET=$MAPROULETTE_CONSUMER_SECRET \ 22 | -DMR_SUPER_ACCOUNTS=8909 \ 23 | -Djavax.net.ssl.trustStore=/MapRouletteV2/conf/osmcacerts \ 24 | -Djavax.net.ssl.trustStorePassword=openstreetmap -------------------------------------------------------------------------------- /docker.conf: -------------------------------------------------------------------------------- 1 | include "application.conf" 2 | 3 | #Below are some useful properties to override. 4 | db.default.url="postgres://mr2dbuser:mr2dbpassword@mr2-postgis:5432/mr2_prod" 5 | #db.default.pool="bonecp" 6 | #db.default.bonecp.logStatements=true 7 | #db.default.bonecp.maxConnectionsPerPartition=200 8 | #db.default.bonecp.minConnectionsPerPartition=10 9 | #db.default.hikaricp.maximumPoolSize=200 10 | #maproulette.action.level=3 11 | #maproulette.logo="/assets/images/companylogo.png" 12 | #maproulette.limits.challenges=3 13 | #maproulette.limits.activities=10 14 | #maproulette.super.key= 15 | #maproulette.super.accounts= 16 | #osm.server="http://api06.dev.openstreetmap.org" 17 | #osm.consumerKey="CHANGE_ME" 18 | #osm.consumerSecret="CHANGE_ME" 19 | #play.http.parser.maxDiskBuffer=100M 20 | #play.http.parser.maxMemoryBuffer=100M 21 | #parsers.MultipartFormData.maxLength=100M 22 | #mr3.staticPath=/MapRouletteV2/static/ -------------------------------------------------------------------------------- /deploy_openstack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script will initialize the open stack docker-machine 3 | # Source your keystone credentials, so that the environment variables are present, otherwise this will fail. 4 | # See https://docs.docker.com/machine/drivers/openstack/ for more information 5 | INSTANCE_NAME="MapRoulette2" 6 | if [ -n "$1" ]; then 7 | INSTANCE_NAME="$1" 8 | fi 9 | docker-machine create --driver openstack\ 10 | --openstack-ssh-user ubuntu\ 11 | --openstack-image-name ubuntu_15.10\ 12 | --openstack-flavor-name m1.medium\ 13 | --openstack-floatingip-pool [CHANGE_ME]\ 14 | --openstack-sec-groups default\ 15 | --openstack-keypair-name [CHANGE_ME]\ 16 | --openstack-private-key-file [CHANGE_ME]\ 17 | --openstack-availability-zone common\ 18 | --openstack-net-name [CHANGE_ME]\ 19 | $INSTANCE_NAME 20 | 21 | status=$(docker-machine status $INSTANCE_NAME) 22 | if [ "$status" != "Running" ]; then 23 | docker-machine start $INSTANCE_NAME 24 | fi 25 | docker-machine env $INSTANCE_NAME 26 | eval "$(docker-machine env $INSTANCE_NAME)" 27 | 28 | export rpg=false 29 | ./run_docker.sh 30 | -------------------------------------------------------------------------------- /run_docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # environment variables that can be set 3 | if [ -z "$DOCKER_VERSION" ]; then 4 | DOCKER_VERSION=1.0.0 5 | fi 6 | if [ -z "$DOCKER_USER" ]; then 7 | DOCKER_USER="maproulette" 8 | fi 9 | #This line gets the latest commit hash to use as the cachebust, when it changes the 10 | #it will break the cache on the line just before we pull the code. So that it won't use 11 | #the cache and instead will pull the latest and repackage 12 | export CACHEBUST=`git ls-remote https://github.com/maproulette/maproulette2.git | grep HEAD | cut -f 1` 13 | export FRONTCACHEBUST=`git ls-remote https://github.com/osmlab/maproulette3.git | grep HEAD | cut -f 1` 14 | docker build -t $DOCKER_USER/maproulette2:$DOCKER_VERSION --build-arg CACHEBUST=$CACHEBUST --build-arg FRONTCACHEBUST=$FRONTCACHEBUST . 15 | 16 | if [ "$wipe_db" == true ]; then 17 | echo "Stopping and removing mr2-postgis container" 18 | docker stop mr2-postgis 19 | docker rm mr2-postgis 20 | fi 21 | 22 | instance=$(docker ps -a | grep mdillon/postgis) 23 | if [ -z "$instance" ]; then 24 | echo "Building new mr2-postgis container" 25 | docker run --name mr2-postgis \ 26 | -e POSTGRES_DB=mr2_prod \ 27 | -e POSTGRES_USER=mr2dbuser \ 28 | -e POSTGRES_PASSWORD=mr2dbpassword \ 29 | -d mdillon/postgis 30 | sleep 10 31 | fi 32 | instance=$(docker ps | grep mdillon/postgis) 33 | if [ -z "$instance" ]; then 34 | echo "Restarting mr2-postgis container" 35 | docker start mr2-postgis 36 | fi 37 | 38 | echo "Stopping and removing maproulette2 container" 39 | docker stop maproulette2 40 | docker rm maproulette2 41 | echo "Building maproulette2 container" 42 | docker run -t --privileged -d -p 80:80 \ 43 | --name maproulette2 \ 44 | --link mr2-postgis:db \ 45 | $DOCKER_USER/maproulette2:$DOCKER_VERSION 46 | 47 | docker ps 48 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8-jdk 2 | 3 | RUN export TERM=xterm 4 | 5 | # Add the User 6 | RUN adduser -system --gid 0 maproulette 7 | 8 | # Apt-Get for basic packages 9 | RUN apt-get update && apt-get upgrade -y && apt-get install -y apt-transport-https 10 | RUN echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list 11 | RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823 12 | RUN apt-get update && apt-get upgrade -y && apt-get install -y scala sbt unzip wget git openssh-server jq g++ build-essential 13 | EXPOSE 80 14 | 15 | ARG CACHEBUST=1 16 | RUN echo $CACHEBUST 17 | # Download Maproulette V2 18 | RUN git clone https://github.com/maproulette/maproulette2.git 19 | RUN chmod 777 /maproulette2 20 | WORKDIR /maproulette2 21 | 22 | # package Maproulette V2 23 | RUN export API_HOST=maproulette.org;sbt clean compile dist 24 | RUN unzip -d / target/universal/MapRouletteV2.zip 25 | WORKDIR /MapRouletteV2 26 | 27 | # Install Yarn and Nodejs 28 | RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - 29 | RUN apt-get install -y nodejs 30 | RUN curl -o- -L https://yarnpkg.com/install.sh | bash 31 | 32 | ARG FRONTCACHEBUST=1 33 | RUN echo $FRONTCACHEBUST 34 | # Download Maproulette Frontend 35 | RUN git clone https://github.com/osmlab/maproulette3.git /maproulette-frontend 36 | RUN chmod 755 /maproulette-frontend 37 | ADD .env.production /maproulette-frontend/.env.production 38 | 39 | # Build the Maproulette Frontend 40 | WORKDIR /maproulette-frontend 41 | RUN export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH";yarn install 42 | RUN export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH";yarn run build 43 | RUN mkdir /MapRouletteV2/static/ 44 | RUN cp -rf /maproulette-frontend/build/* /MapRouletteV2/static/ 45 | 46 | # Retrieve OSM & Mapillary Certificates 47 | WORKDIR / 48 | RUN openssl s_client -showcerts -connect "www.openstreetmap.org:443" -servername www.openstreetmap.org osm.pem 49 | RUN openssl s_client -showcerts -connect "a.mapillary.com:443" -servername a.mapillary.com mapillary.pem 50 | RUN keytool -importcert -noprompt -trustcacerts -alias a.mapillary.com -file mapillary.pem -keystore osmcacerts -storepass openstreetmap 51 | RUN keytool -importcert -noprompt -trustcacerts -alias www.openstreetmap.org -file osm.pem -keystore osmcacerts -storepass openstreetmap 52 | 53 | # Bootstrap commands 54 | ADD bootstrap.sh /etc/bootstrap.sh 55 | ADD setupServer.sh /MapRouletteV2/setupServer.sh 56 | ADD docker.conf /MapRouletteV2/conf/docker.conf 57 | RUN chmod 777 /etc/bootstrap.sh 58 | RUN chmod 777 /MapRouletteV2/setupServer.sh 59 | WORKDIR /MapRouletteV2 60 | # Move the truststore to the correct location 61 | RUN mv /osmcacerts conf/ 62 | 63 | ENTRYPOINT ["/etc/bootstrap.sh"] 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Map Roulette 2 in Docker 2 | Docker image for Map Roulette 2. This tool creates both a map roulette image and a postgres-postgis image. The postgis image is using [https://hub.docker.com/r/mdillon/postgis/](mdillon/postgis). A default database is created mr2_prod and the container is linked to the MapRoulette 2 container. 3 | 4 | # Creating Instances 5 | 6 | ### Setting up Configuration 7 | 8 | There are a couple of required properties that you will need to setup prior to running the docker.sh shell script. These settings need to be updated in the docker.conf file, look for the "CHANGE_ME" fields. 9 | 10 | * DOCKER_USER - This is the username of the user setting up the docker images, if not supplied will default to "maproulette" 11 | * MAPROULETTE_DB_URL - This is the location of the database. This is set to the linked postgres docker container, so doesn't need to be explicitly set unless using a different database. 12 | * MAPROULETTE_CONSUMER_KEY - This is the consumer key for your MapRoulette application in your openstreetmap.org account. 13 | * MAPROULETTE_CONSUMER_SECRET - This is the consumer secret that is found in the same MapRoulette application settings as is the consumer key. 14 | 15 | Other properties that are useful to know about. 16 | 17 | * maproulette.super.key - This is the api key that can be used for any API requests and the server will assume that the person making the request is a super user. No requirement to login. 18 | * maproulette.super.accounts - This is a comma separated list of OSM account ids that will be elevated to super user access when they login. 19 | 20 | ### Running docker.sh 21 | 22 | To create the MapRoulette and Postgis docker instance you just need to execute the docker.sh script. This will build the two instances and link them together. By default the Map Roulette service will start up on port 80, if you need to change this you will need to change the port in the following places: 23 | 24 | * Dockerfile line 13 25 | * run_docker.sh line 26 26 | * setupServer.sh line 14 27 | 28 | ### Deploying to Open stack 29 | 30 | Running docker.sh will deploy the containers locally and will require the user to have VirtualBox setup correctly. Alternatively you can run deploy_openstack.sh and deploy the containers to an OpenStack environment. The most important thing that this requires is that you have your Keystone credentials sourced into your environment. Please refer to your openstack documentation for information about your keystone credentials and where to get them. Other than that you will need to edit the deploy_openstack.sh file lines 6 through 14 which contain properties for the image that you want to create for your containers. 31 | 32 | ### Deploying to other environments 33 | 34 | You can create your own shell scripts to deploy to various other environments as well, please refer to the docker documentation [https://docs.docker.com/machine/drivers/](here). If you do create your own scripts please don't hesistate to create a PR into this repo. 35 | 36 | # Thanks 37 | 38 | To [https://github.com/matthieun](https://github.com/matthieun) for the docker work on the original Map Roulette which I used a bit as reference. 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------