-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from trustrachel/hackpad-docker
Dockerize Hackpad
- Loading branch information
Showing
4 changed files
with
197 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 '[email protected]' 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 '[email protected]' 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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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__:[email protected]:' -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 '[email protected]'." | ||
echo | ||
|
||
./bin/run.sh | ||
|
||
elif [[ "$1" = 'server' ]]; then | ||
echo | ||
echo "Starting server." | ||
echo | ||
|
||
./bin/run.sh | ||
|
||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters