Skip to content

Commit

Permalink
production builds working
Browse files Browse the repository at this point in the history
Former-commit-id: fc252e8
  • Loading branch information
hjwilli committed May 13, 2019
1 parent fe8062d commit 5325441
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Docker production build environment
TAG=0.12
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,48 @@ The default location of the test output is the `.\target\test-reports\` director
# note the path of test.js need to be updated in Windows environment
mocha ./test/test.js # or `npm test`
```

# Generating and publishing production builds

1. Update the TAG environment variable in `.env` to the current production version as per [semantic versioning](https://semver.org/)
2. Push the code to github, merge it to the production branch and tag it with the tag in the .env file
3. Build the production images using `docker-compose -f docker-compose-production.yml build`. This will create local lab, machine, and dbmongo images with the tag defined in the .env file.
4. Create a production directory and copy the config files, the .env file, and the production docker compose file, and make an images directory:
```
#!/bin/bash
PROD_DIR = "pennai-${TAG}"
mkdir -p $PROD_DIR
mkdir -p "$PROD_DIR/images"
cp -R config "${PROD_DIR}/config"
cp config/ai.env-template "${PROD_DIR}/config/ai.env-template"
cp .env "${PROD_DIR}/.env"
cp docker-compose-production.yml "${PROD_DIR}/docker-compose.yml"
```

5. Export the production images into the images directory
```
cd PROD_DIR
docker save --output pennai_lab.tar "pennai_lab:${TAG}"
docker save --output pennai_machine.tar "pennai_machine:${TAG}"
docker save --output pennai_dbmongo.tar "pennai_dbmongo:${TAG}"
```

5. Zip the production directory
6. Create a github release using the tagged production commit, and attach the zipped production directory as an archive


# Installing a production build
1. Download a production build from github
2. Unzip the archive
3. Load the images into docker with the following commands:
```
docker load --input .\images\pennai_lab.tar
docker load --input .\images\pennai_machine.tar
docker load --input .\images\pennai_dbmongo.tar
```

# Running from production build
1. From the pennai directory, run the command `docker-compose up` to start the PennAI server.
2 changes: 2 additions & 0 deletions config/ai.env-template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# AI_TERM_COND: how AI stops recommending. n_recs, time or continuous
# AI_MAX_TIME: maximum time in seconds to recommend when using 'n_recs'
# AI_NUMRECOMMEND: how many recommendations the AI will make when toggled when using 'time'


AI_AUTOSTART=1
AI_RECOMMENDER=svd
AI_VERBOSE=1
Expand Down
1 change: 0 additions & 1 deletion config/common.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Common envronmental variables consumed by docker-compose.yml
# TODO - was generated by examining the output produced by awsm/make.js; needs to be cleaned up
NETWORK=pennai
PARENTDB=demo
CAPACITY=1
Expand Down
6 changes: 6 additions & 0 deletions docker-compose-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ services:
build:
context: .
dockerfile: dockers/lab/Dockerfile_production
image: "pennai_lab:${TAG}"
tty: true
stdin_open: true
volumes:
- "/appsrc"
- "./data/datasets/user:/appsrc/data/datasets/user"
- "./target:/appsrc/target"
ports:
- "443:443"
- "5080:5080"
Expand All @@ -22,10 +25,12 @@ services:
build:
context: .
dockerfile: dockers/machine/Dockerfile_production
image: "pennai_machine:${TAG}"
tty: true
stdin_open: true
volumes:
- "/appsrc"
- "./target:/appsrc/target"
ports:
- "5081:5081"
env_file: ./config/common.env
Expand All @@ -39,6 +44,7 @@ services:
build:
context: .
dockerfile: dockers/dbmongo/Dockerfile
image: "pennai_dbmongo:${TAG}"
tty: true
stdin_open: true
ports:
Expand Down
5 changes: 3 additions & 2 deletions dockers/lab/Dockerfile_production
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ FROM pennai/base:latest
# copy src for lab
COPY lab /appsrc/lab
COPY ai /appsrc/ai
COPY data /appsrc/data

WORKDIR /opt/
ARG docker_filepath=dockers/lab/files
Expand Down Expand Up @@ -48,6 +47,9 @@ COPY ${docker_filepath}/001-pennai.conf /etc/apache2/sites-enabled/
COPY ${docker_filepath}/htpasswd /etc/apache2/htpasswd
COPY ${docker_filepath}/certs/* /usr/lib/ssl/private/

# data directories
WORKDIR /
COPY data /appsrc/data

WORKDIR /root/

Expand All @@ -67,7 +69,6 @@ RUN dos2unix /root/start.sh \
&& dos2unix /root/wait-for-it.sh \
&& dos2unix /root/entrypoint.sh


# Start the webserver
CMD ["/bin/bash", "/root/start.sh"]

Expand Down

0 comments on commit 5325441

Please sign in to comment.