Skip to content
This repository was archived by the owner on Jun 20, 2021. It is now read-only.

Commit 6004c95

Browse files
author
Regis FLORET
authored
Merge pull request #4 from regisf/add-docker
Refactorize and add docker for easy deployment
2 parents 5cd1395 + c274365 commit 6004c95

File tree

9 files changed

+58
-35
lines changed

9 files changed

+58
-35
lines changed

Application/App/models/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
Create the connection for all models
2121
2222
"""
23+
import os
2324
from pymongo import MongoClient
25+
2426
import private_settings
2527

26-
_client = MongoClient('localhost')
28+
_client = MongoClient(os.environ.get('PYTHONREGEX_DATABASE'))
2729
database = _client[private_settings.DB_NAME]
28-

Application/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run_app():
4141
URLS,
4242
debug=settings.DEBUG,
4343
template_path=settings.ROOT_TEMPLATE_PATH,
44-
cookie_secret=config.get('secret_key'),
44+
cookie_secret=config.get('secret_key', os.environ.get('PYTHONREGEX_SECRET_COOKIE')),
4545

4646
# Set keys for OAuth transaction
4747
twitter_consumer_key=config.get('twitter_consumer_key'),

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM python:alpine
2+
3+
MAINTAINER Regis FLORET <regisfloret@gmail.com>
4+
5+
LABEL com.python-regex.version="1.0.1"
6+
7+
# Change for the project
8+
9+
WORKDIR pythonregex
10+
11+
COPY requirements.txt requirements.txt
12+
COPY Application Application
13+
COPY bin bin
14+
15+
RUN pip install -r requirements.txt
16+
17+
EXPOSE 8888
18+
19+
CMD ["bin/start.sh"]

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
PythonRegex
2-
===========
1+
# PythonRegex
32

43
A web site build with Tornado to replace Kodos3. It use Python 3.3 and MongoDB for the database.
54

5+
6+
## Configuration
7+
8+
You have to setup on single environment variable:
9+
10+
* PYTHONREGEX_SECRET_COOKIE which is your secret key for the web site.
11+
12+
## Run
13+
14+
Simply run:
15+
16+
`$ docker-compose run --build `

bin/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22

33
. ./bin/tests.sh
44

5-
cd build
65
docker build $1 -t pythonregex/web .

bin/start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22

33
printf "Starting PythonRegex application in \033[1m"
44
if [ "$1" = "--dev" ]; then printf "DEVELOPER"; else printf "PRODUCTION"; fi; printf "\033[0m mode\n"
55

66
cd Application
7-
python3 main.py $1
7+
python main.py $1

bin/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22

33
printf "Testing project\n"
44

build/Dockerfile

Lines changed: 0 additions & 25 deletions
This file was deleted.

docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3'
2+
3+
services:
4+
pythonregex:
5+
build: .
6+
container_name: pythonregex
7+
image: pythonregex/web
8+
9+
ports:
10+
- '8888:8888'
11+
12+
environment:
13+
- PYTHONREGEX_DATABASE=db
14+
15+
db:
16+
image: 'mongo:3.5'
17+
hostname: 'db'
18+

0 commit comments

Comments
 (0)