Skip to content

Commit

Permalink
Refactor docker image builder
Browse files Browse the repository at this point in the history
  • Loading branch information
dougppaz committed Aug 24, 2018
1 parent 2694d59 commit 92de9c6
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 71 deletions.
8 changes: 2 additions & 6 deletions docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ FROM python:3.6-alpine3.7
ENV WORKDIR /home/app
WORKDIR $WORKDIR

RUN apk update && apk upgrade
RUN apk add alpine-sdk postgresql-dev nodejs nginx
RUN apk update && apk add alpine-sdk postgresql-dev

RUN pip install pipenv
RUN pip install gunicorn
Expand All @@ -16,9 +15,6 @@ COPY Pipfile.lock Pipfile.lock
RUN pipenv install --system

COPY . .
COPY ./docker/bothub-nginx.conf /etc/nginx/conf.d/default.conf
COPY ./docker/entrypoint.sh ./entrypoint.sh

RUN chmod +x ./entrypoint.sh
EXPOSE 80
ENTRYPOINT $WORKDIR/entrypoint.sh
ENTRYPOINT [ "./entrypoint.sh" ]
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,3 @@ You can set environment variables in your OS, write on ```.env``` file or pass v
| BOTHUB_NLP_BASE_URL | ```string``` | ```http://localhost:2657/``` | The bothub-blp production application URL. Used to proxy requests.
| CHECK_ACCESSIBLE_API_URL | ```string``` | ```http://localhost/api/repositories/``` | URL used by ```bothub.health.check.check_accessible_api``` to make a HTTP request. The response status code must be 200.
| SEND_EMAILS | ```boolean``` | ```True``` | Send emails flag.

### Docker Environment Variables

| Variable | Type | Default | Description |
|--|--|--|--|
| BUILD_WEBAPP | ```boolean``` | ```true``` | Build webapp application in entrypoint.
| WEBAPP_REPO | ```string``` | ```https://github.com/Ilhasoft/bothub-webapp``` | bothub-webapp git repository URL. It will clone and run ```npm install && npm run build``` command on the entrypoint. This build is served by Nginx.
| WEBAPP_BRANCH | ```string``` | ```master``` | Specify the branch of the bothub-webapp Git repository.
| API_BASE_URL | ```string``` | Not defined | The bothub production application URL. Used by ```bothub-webapp``` application.
8 changes: 2 additions & 6 deletions docker/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ services:
bothub:
image: ${DOCKER_IMAGE_NAME:-ilha/bothub}:${TAG:-latest}
build:
context: ..
dockerfile: docker/Dockerfile
context: .
dockerfile: Dockerfile
ports:
- 80:80
environment:
Expand All @@ -36,10 +36,6 @@ services:
- CSRF_COOKIE_SECURE=${CSRF_COOKIE_SECURE:-false}
- BOTHUB_WEBAPP_BASE_URL=${BOTHUB_WEBAPP_BASE_URL:-http://localhost/}
- BOTHUB_NLP_BASE_URL=${BOTHUB_NLP_BASE_URL:-http://localhost:2657/}
- BUILD_WEBAPP=${BUILD_WEBAPP:-true}
- WEBAPP_REPO=${WEBAPP_REPO:-https://github.com/Ilhasoft/bothub-webapp}
- WEBAPP_BRANCH=${WEBAPP_BRANCH:-master}
- API_BASE_URL=${API_BASE_URL:-/api}
- CHECK_ACCESSIBLE_API_URL=${CHECK_ACCESSIBLE_API_URL}
- SEND_EMAILS=${SEND_EMAILS:-true}
- SUPPORTED_LANGUAGES=${SUPPORTED_LANGUAGES:-en|pt}
31 changes: 0 additions & 31 deletions docker/bothub-nginx.conf

This file was deleted.

17 changes: 0 additions & 17 deletions docker/entrypoint.sh

This file was deleted.

6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
cd $WORKDIR
python manage.py migrate
python manage.py collectstatic --noinput

gunicorn bothub.wsgi -c gunicorn.conf.py
3 changes: 1 addition & 2 deletions docker/gunicorn.conf.py → gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import multiprocessing

bind = 'unix:/tmp/bothub.sock'
bind = '0.0.0.0:80'
workers = multiprocessing.cpu_count() * 2 + 1
raw_env = ['DJANGO_SETTINGS_MODULE=bothub.settings']
daemon = True

0 comments on commit 92de9c6

Please sign in to comment.