Merge pull request #26 from trustrachel/hackpad-docker
Dockerize Hackpad
This commit is contained in:
68
DOCKER.md
Normal file
68
DOCKER.md
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
How to develop Hackpad under Docker
|
||||||
|
===================================
|
||||||
|
|
||||||
|
If you'd like to develop Hackpad on Docker, these instructions are for you.
|
||||||
|
|
||||||
|
This will let you edit this repository and see your changes reflected in the docker image.
|
||||||
|
|
||||||
|
Getting it running
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
1. Obviously, if you haven't already, you'll need to install [Docker](https://docs.docker.com/installation/).
|
||||||
|
|
||||||
|
2. Build the image. From the root of this repo, run:
|
||||||
|
|
||||||
|
docker build -t hackpad .
|
||||||
|
|
||||||
|
3. Run the container. Docker doesn't let you automatically mount a directory on your host machine in the container, so you'll need to specify by hand.
|
||||||
|
|
||||||
|
Replace /path/to/this/repo below with the path to the current repository. Leave the other path alone.
|
||||||
|
|
||||||
|
docker run -d -p 9000:9000 -v /path/to/this/repo:/etc/hackpad/src hackpad
|
||||||
|
|
||||||
|
This will build hackpad, run schema migrations, and then start the server. It may take a few minutes. If you want to see what's going on, do:
|
||||||
|
|
||||||
|
docker logs -f [container name]
|
||||||
|
|
||||||
|
4. Fix networking (one time only). If you're on OS X or Windows, you'll need to set up port forwarding to have Hackpad work properly. Linux folk can skip this.
|
||||||
|
|
||||||
|
1. Open VirtualBox
|
||||||
|
|
||||||
|
2. Select the `default` image and click Settings
|
||||||
|
|
||||||
|
3. Go to Network -> Adapter 1 -> Port forwarding
|
||||||
|
|
||||||
|
4. Create a custom rule like so:
|
||||||
|
|
||||||
|
* Host IP: 127.0.0.1
|
||||||
|
* Host Port: 9000
|
||||||
|
* Guest IP: blank
|
||||||
|
* Guest Port: 9000
|
||||||
|
|
||||||
|
You should only have to do this once.
|
||||||
|
|
||||||
|
At this point you should be able to open http://localhost:9000 in a browser and see the Hackpad page.
|
||||||
|
|
||||||
|
5. Create a password for the admin account.
|
||||||
|
|
||||||
|
As part of the Docker setup, Hackpad is configured with 'admin@localhost.info' as a admin account, but you'll need to create a password to log in.
|
||||||
|
|
||||||
|
To do that:
|
||||||
|
|
||||||
|
1. Open http://localhost:9000 and click Log In
|
||||||
|
|
||||||
|
2. Create an account with 'admin@localhost.info' and any password you like.
|
||||||
|
|
||||||
|
3. From the command line, run:
|
||||||
|
|
||||||
|
1. Find the name of your running container by running `docker ps`. Note the name.
|
||||||
|
|
||||||
|
2. Run this query and find the token:
|
||||||
|
|
||||||
|
docker exec -it [container name] mysql -D hackpad -e 'select * from email_signup;'
|
||||||
|
|
||||||
|
3. Load this in a browser: http://localhost:9000/ep/account/validate-email?email=admin%40localhost.info&token=TOKEN
|
||||||
|
|
||||||
|
|
||||||
|
You're all set! You should be able to edit the Hackpad source code and the docker container will track those changes.
|
||||||
|
|
||||||
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from ubuntu:14.04
|
||||||
|
|
||||||
|
RUN apt-get -y update
|
||||||
|
|
||||||
|
RUN apt-get install -yf \
|
||||||
|
openjdk-7-jdk \
|
||||||
|
mysql-server \
|
||||||
|
scala
|
||||||
|
|
||||||
|
RUN mkdir /etc/hackpad
|
||||||
|
|
||||||
|
VOLUME /etc/hackpad/src
|
||||||
|
|
||||||
|
COPY bin/docker-entrypoint.sh /etc/hackpad/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/etc/hackpad/docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
EXPOSE 9000
|
||||||
|
|
||||||
|
CMD ["hackpad"]
|
||||||
59
bin/docker-entrypoint.sh
Executable file
59
bin/docker-entrypoint.sh
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
HACKPAD_SRC="/etc/hackpad/src"
|
||||||
|
|
||||||
|
if [ "$1" = 'hackpad' ]; then
|
||||||
|
|
||||||
|
if [ ! -d "$HACKPAD_SRC" ]; then
|
||||||
|
echo "The directory $HACKPAD_SRC doesn't exist."
|
||||||
|
echo "You're probably running this on the host machine and not in the Docker container. Don't do that."
|
||||||
|
echo "If this is happening on the Docker container, try building a new image from scratch."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$HACKPAD_SRC"
|
||||||
|
|
||||||
|
# sanity check that we see any files at all.
|
||||||
|
if [ ! -f "$HACKPAD_SRC/README.md" ]; then
|
||||||
|
echo "I can't find any Hackpad source files. Did you forget to mount the volume?"
|
||||||
|
echo "e.g., docker run -d -p 9000:9000 -v /path/to/this/repo:/etc/hackpad/src hackpad"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "-->Editing configuration files"
|
||||||
|
|
||||||
|
sed 's:^export SCALA_HOME=".*$:export SCALA_HOME="/usr/share/java":' -i'' bin/exports.sh
|
||||||
|
sed 's:^export SCALA_LIBRARY_JAR=".*$:export SCALA_LIBRARY_JAR="$SCALA_HOME/scala-library.jar":' -i'' bin/exports.sh
|
||||||
|
sed 's:^export JAVA_HOME=".*$:export JAVA_HOME="/usr/share/java":' -i'' bin/exports.sh
|
||||||
|
|
||||||
|
cp etherpad/etc/etherpad.localdev-default.properties etherpad/etc/etherpad.local.properties
|
||||||
|
sed 's:__email_addresses_with_admin_access__:admin@localhost.info:' -i'' etherpad/etc/etherpad.local.properties
|
||||||
|
|
||||||
|
echo "-->Running build"
|
||||||
|
|
||||||
|
./bin/build.sh
|
||||||
|
|
||||||
|
echo "-->Starting mysql"
|
||||||
|
service mysql restart
|
||||||
|
|
||||||
|
echo "-->Creating database"
|
||||||
|
./contrib/scripts/setup-mysql-db.sh -p ""
|
||||||
|
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Starting server. The admin account is 'admin@localhost.info'."
|
||||||
|
echo
|
||||||
|
|
||||||
|
./bin/run.sh
|
||||||
|
|
||||||
|
elif [[ "$1" = 'server' ]]; then
|
||||||
|
echo
|
||||||
|
echo "Starting server."
|
||||||
|
echo
|
||||||
|
|
||||||
|
./bin/run.sh
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
@@ -14,12 +14,57 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
db="hackpad"
|
MYSQL="mysql"
|
||||||
mysql="mysql"
|
DATABASE="hackpad"
|
||||||
echo "Creating database ${db}..."
|
DB_USERNAME=root
|
||||||
echo "create database ${db};" | ${mysql} -u root -p
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
PROMPT=true
|
||||||
|
|
||||||
|
while [[ $# > 0 ]]
|
||||||
|
do
|
||||||
|
key="$1"
|
||||||
|
|
||||||
|
case $key in
|
||||||
|
|
||||||
|
-d|--database)
|
||||||
|
DATABASE="$2"
|
||||||
|
shift # past argument=value
|
||||||
|
;;
|
||||||
|
-u|--username)
|
||||||
|
DB_USERNAME="$2"
|
||||||
|
shift # past argument=value
|
||||||
|
;;
|
||||||
|
-p|--password)
|
||||||
|
DB_PASSWORD="$2"
|
||||||
|
PROMPT=false
|
||||||
|
shift # past argument=value
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# unknown option
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$PROMPT" == true ]; then
|
||||||
|
MYSQL_CMD="${MYSQL} -u ${DB_USERNAME} -p"
|
||||||
|
else
|
||||||
|
if [ -z "$DB_PASSWORD" ]; then
|
||||||
|
|
||||||
|
MYSQL_CMD="${MYSQL} -u ${DB_USERNAME}"
|
||||||
|
else
|
||||||
|
MYSQL_CMD="${MYSQL} -u ${DB_USERNAME} -p ${DB_PASSWORD}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "Creating database ${DATABASE}..."
|
||||||
|
echo "create database ${DATABASE};" | ${MYSQL_CMD}
|
||||||
|
|
||||||
|
|
||||||
echo "Granting priviliges..."
|
echo "Granting priviliges..."
|
||||||
echo "grant all privileges on ${db}.* to 'hackpad'@'localhost' identified by 'password';" | ${mysql} -u root -p
|
echo "grant all privileges on ${DATABASE}.* to 'hackpad'@'localhost' identified by 'password';" | ${MYSQL_CMD}
|
||||||
|
|
||||||
echo "Success"
|
echo "Success"
|
||||||
|
|||||||
Reference in New Issue
Block a user