Skip to content

Commit

Permalink
Merge pull request #1 from remstef/master
Browse files Browse the repository at this point in the history
minor docker adaptations
  • Loading branch information
Thylossus authored Nov 16, 2016
2 parents cf4b564 + 06932da commit a475752
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 31 deletions.
63 changes: 33 additions & 30 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,42 @@ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y nodejs

# Install Nginx
RUN apt-get install -y nginx
RUN apt-get install -y nginx apache2-utils

# Install python + dependencies
RUN apt-get install -y python3 python3-pip
RUN pip3 install pymongo

# Create database and temp directory
RUN mkdir /data && mkdir /temp

# Copy resources
# Expecting the following files in this directory
# - images.tar.gz
# - dbdump.tgz
# - mongod.conf
COPY ./images.tar.gz /temp/
COPY ./dbdump.tgz /temp/
COPY ./mongod.conf /etc/

# Restore database dump
RUN mkdir /temp/dbdump && tar -xzvf /temp/dbdump.tgz -C /temp/dbdump
RUN mkdir /logs && touch /logs/mongod.log
RUN mongod -f /etc/mongod.conf --fork --logappend --logpath /logs/mongod.log && \
mongorestore --host localhost --port 27017 /temp/dbdump/2016-10-21_06h34m.Friday

# Create directory for client and images
RUN mkdir -p /var/www/html/mci/img/movies

# Extract and copy images
WORKDIR /temp
RUN tar -xzvf images.tar.gz -C /var/www/html/mci/img/movies

# Download repository
WORKDIR /code
RUN echo "Loading source code from repo https://github.com/Thylossus/tud-movie-character-insights"
RUN git clone https://github.com/Thylossus/tud-movie-character-insights

# Create directory for client and images
RUN mkdir -p /var/www/html/mci/img/movies

# Build client
WORKDIR /code/tud-movie-character-insights/Client
RUN npm install
Expand All @@ -53,48 +75,29 @@ RUN cp ./build/* /var/www/html/mci
WORKDIR /code/tud-movie-character-insights/Server/app
RUN npm install --production
RUN mkdir /Server
RUN htpasswd -b -c /Server/.demopass demo pass
RUN cp -R /code/tud-movie-character-insights/Server/* /Server

# Cleanup
RUN rm -rf /code
RUN rm -rf /temp
RUN rm -rf /var/lib/apt/lists/*

# Create empty certificates so that the server won't fail to start
RUN mkdir /Server/dbCerts && \
touch /Server/dbCerts/CAChain.pem && \
touch /Server/dbCerts/Mongodb.pem

# Create database and temp directory
RUN mkdir /data && mkdir /temp

# Copy resources
# Expecting the following files in this directory
# - images.tar.gz
# - dbdump.tgz
# Copy configuration resources
# - nginx.conf
# - mongod.conf
# - startup.sh
# - server.user.conf
COPY ./images.tar.gz /temp/
COPY ./dbdump.tgz /temp/
COPY ./nginx.conf /etc/nginx/
COPY ./mongod.conf /etc/
COPY startup.sh /Server/
COPY server.user.conf /Server/

# Restore database dump
RUN mkdir /temp/dbdump && tar -xzvf /temp/dbdump.tgz -C /temp/dbdump
RUN mkdir /logs && touch /logs/mongod.log
RUN mongod -f /etc/mongod.conf --fork --logappend --logpath /logs/mongod.log && \
mongorestore --host localhost --port 27017 /temp/dbdump/2016-10-21_06h34m.Friday

# Extract and copy images
WORKDIR /temp
RUN tar -xzvf images.tar.gz -C /var/www/html/mci/img/movies

WORKDIR /Server

# Cleanup
RUN rm -rf /code
RUN rm -rf /temp
RUN rm -rf /var/lib/apt/lists/*

# Expose ports
EXPOSE 80

Expand Down
9 changes: 9 additions & 0 deletions Docker/build_and_run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

docker build . -t moviecharacterinsight:demo

docker run -d -p ${1:-8181}:80 --name moviecharacterinsights moviecharacterinsight:demo

docker cp server.user.conf moviecharacterinsights:/Server/

docker logs -f moviecharacterinsights
2 changes: 2 additions & 0 deletions Docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ http {
}

location / {
auth_basic 'Enter demo and pass';
auth_basic_user_file /Server/.demopass;
try_files $uri $uri/ /index.html;
}
}
Expand Down
9 changes: 9 additions & 0 deletions Docker/server.user.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dir.base=/Server

mongo.connection.mode=local
mongo.dbname=characterinsights

mongo.url=mongodb://localhost/${mongo.dbname}

watsonCredentialsUsername=<ADD USERNAME FOR PERSONALITY INSIGHTS SERVICE INSTANCE>
watsonCredentialsPassword=<ADD PASSWORD FOR PERSONALITY INSIGHTS SERVICE INSTANCE>
5 changes: 4 additions & 1 deletion Docker/startup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
echo "starting in 5 seconds, please copy server.user.conf now"
sleep 5
nginx
mongod -f /etc/mongod.conf --fork --logappend --logpath /logs/mongod.log

Expand All @@ -10,6 +12,7 @@ ps aux | grep mongod
echo "nginx started?"
ps aux | grep nginx

# echo "Starting app"
echo "Starting app"
cat /Server/server.user.conf
cd /Server/app
node app.js

0 comments on commit a475752

Please sign in to comment.