Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial Dockerfile and entrypoints for docker-compose * Fix building dockerfile. * Add docker-compose. * Add settings_local.py * Rename silver image. * Add drone file. * Run test with mysql. * Make tests run on sqllite.
- Loading branch information
Showing
8 changed files
with
142 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM python:2.7.11-alpine | ||
MAINTAINER Presslabs ping@presslabs.com | ||
|
||
# Ensure that Python outputs everything that's printed inside | ||
# the application rather than buffering it, maily for logging purposes | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Set default django settings module | ||
ENV DJANGO_SETTINGS_MODULE settings_local | ||
|
||
# silver app runs on port 8080 | ||
EXPOSE 8080 | ||
|
||
RUN set -ex && mkdir -p /silver | ||
WORKDIR /silver | ||
|
||
# Install silver | ||
COPY ./requirements /silver/requirements | ||
|
||
RUN set -ex \ | ||
&& apk update \ | ||
&& apk add --no-cache \ | ||
mariadb-client-libs \ | ||
libjpeg-turbo \ | ||
jpeg \ | ||
zlib \ | ||
ca-certificates wget \ | ||
openssl \ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
build-base \ | ||
mariadb-dev \ | ||
jpeg-dev \ | ||
zlib-dev \ | ||
&& update-ca-certificates \ | ||
&& pip install --no-cache-dir -r requirements/common.txt \ | ||
&& pip install --no-cache-dir gunicorn==19.4.5 \ | ||
&& pip install --no-cache-dir mysql-python \ | ||
&& apk del .build-deps \ | ||
&& wget -qO- https://github.com/jwilder/dockerize/releases/download/v0.2.0/dockerize-linux-amd64-v0.2.0.tar.gz | tar -zxf - -C /usr/bin \ | ||
&& chown root:root /usr/bin/dockerize | ||
|
||
COPY ./ /silver | ||
|
||
VOLUME /silver | ||
|
||
CMD ["/docker-entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SILVER_DB_ENGINE=django.db.backends.mysql | ||
SILVER_DB_NAME=silver | ||
SILVER_DB_HOST=db | ||
SILVER_MIGRATE=yes | ||
SILVER_LOAD_DEV_DATA=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '2' | ||
services: | ||
silver: | ||
image: presslabs/silver:latest | ||
command: dockerize -wait tcp://db:3306 -timeout 30s /silver/docker-entrypoint | ||
env_file: ./docker-compose.env | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- .:/silver | ||
|
||
db: | ||
image: mysql:5.5 | ||
environment: | ||
MYSQL_ROOT_PASSWORD: password | ||
MYSQL_DATABASE: silver | ||
MYSQL_USER: silver | ||
MYSQL_PASSWORD: password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ "$SILVER_MIGRATE" == "yes" ] ; then | ||
/usr/local/bin/python2 /silver/manage.py migrate --noinput | ||
fi | ||
|
||
if [ "$SILVER_LOAD_DEV_DATA" == "yes" ] ; then | ||
/usr/local/bin/python2 /silver/manage.py loaddata -i fixtures/initial_dev_data.json | ||
fi | ||
|
||
exec /usr/local/bin/python2 /silver/manage.py runserver 0.0.0.0:8080 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
These settings are used by the ``manage.py`` command. | ||
""" | ||
|
||
import os | ||
|
||
DEBUG = False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import sys | ||
|
||
from settings import * | ||
|
||
DEBUG = True | ||
TEMPLATE_DEBUG = True | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': os.getenv('SILVER_DB_ENGINE', 'django.db.backends.sqlite3'), | ||
'NAME': os.getenv('SILVER_DB_NAME', 'db.sqlite3'), | ||
'USER': os.getenv('SILVER_DB_USER', 'silver'), | ||
'PASSWORD': os.getenv('SILVER_DB_PASSWORD', 'password'), | ||
'HOST': os.getenv('SILVER_DB_HOST', ''), | ||
'PORT': os.getenv('SILVER_DB_PORT', '3306'), | ||
'TEST': { | ||
'CHARSET': 'utf8' | ||
} | ||
} | ||
} | ||
|
||
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '0.0.0.0'] | ||
|
||
if 'test' in sys.argv: | ||
# faster tests | ||
PASSWORD_HASHERS = [ | ||
'django.contrib.auth.hashers.MD5PasswordHasher', | ||
'django.contrib.auth.hashers.PBKDF2PasswordHasher', | ||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher', | ||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher', | ||
'django.contrib.auth.hashers.BCryptPasswordHasher', | ||
'django.contrib.auth.hashers.SHA1PasswordHasher', | ||
'django.contrib.auth.hashers.CryptPasswordHasher', | ||
] | ||
DEBUG = False | ||
TEMPLATE_DEBUG = False | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': 'db.sqlite', | ||
} | ||
} |