diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..b14b1d3b8a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM ubuntu:14.04 + +# install couchdb +RUN apt-get update && apt-get install curl sudo git wget -y + +# install hospital run +RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - +RUN apt-get update && apt-get install nodejs -y +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app +COPY . /usr/src/app +RUN npm install -g npm && npm install -g ember-cli@latest && npm install -g bower +RUN npm install +RUN bower install --allow-root +COPY ./server/config-example.js ./server/config.js + +RUN sed -i -e 's/URL="localhost"/URL="couchdb"/g' ./script/initcouch.sh +RUN sed -i -e "s/couchDbServer: 'localhost'/couchDbServer: 'couchdb'/g" ./server/config.js +RUN sed -i -e "s/localhost:5984/couchdb:5984/g" ./script/server + +EXPOSE 4200 + +ENTRYPOINT ./script/initcouch.sh && npm start diff --git a/README.md b/README.md index 6293c41501..be3b211115 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,17 @@ To start the frontend please do the following: - Start the server by running `npm start` in the repo folder. - Go to [http://localhost:4200/](http://localhost:4200/) in a browser and login with username `hradmin` and password `test`. +## Running with Docker +To run HospitalRun with Docker please do the following: +- Goto [https://docs.docker.com/engine/installation](https://docs.docker.com/engine/installation) to download and install Docker. +- Clone the repository with the command `git clone https://github.com/HospitalRun/hospitalrun-frontend.git`. +- Change to the hospitalrun-frontend directory `cd hosptialrun-frontend`. +- Build the HosptialRun image with `docker build -t hospitalrun-frontend .` +- Execute `docker run -it --name couchdb -d couchdb` to create the couchdb container. +- Execute `docker run -it --name hospitalrun-frontend -p 4200:4200 --link couchdb:couchdb -d hospitalrun-frontend` to create the HospitalRun container. +- Run the following command to get the ip of the docker machine that the image was created on `docker-machine ip default`. +- Go to `http://:4200` in a browser and login with username `hradmin` and password `test`. + ### Troubleshooting your local environment Always make sure to `git pull` and get the latest from master. diff --git a/script/initcouch.sh b/script/initcouch.sh index cf61677218..ed764ae7c7 100755 --- a/script/initcouch.sh +++ b/script/initcouch.sh @@ -1,10 +1,14 @@ #!/bin/bash + +URL="localhost" +PORT="5984" + if [ -z "${1}" ] || [ -z "${2}" ]; then - HOST="http://127.0.0.1:5984" + HOST="http://$URL:$PORT" curl -X PUT $HOST/_config/admins/couchadmin -d '"test"' - SECUREHOST="http://couchadmin:test@127.0.0.1:5984" + SECUREHOST="http://couchadmin:test@$URL:$PORT" else - SECUREHOST="http://$1:$2@127.0.0.1:5984" + SECUREHOST="http://$1:$2@$URL:$PORT" fi curl -X PUT $SECUREHOST/_users/_security -d '{ "admins": { "names": [], "roles": ["admin"]}, "members": { "names": [], "roles": []}}' curl -X PUT $SECUREHOST/config