Changed Dockerfile over to use postgres. Adding custom config for the Dockerfile.

This commit is contained in:
Maxwell Friederichs 2015-12-16 10:38:22 -06:00
parent e3bcb68b11
commit 5357992688
2 changed files with 32 additions and 8 deletions

View file

@ -3,21 +3,29 @@ from ubuntu
# Patch and Install Dependencies
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get -y install git python-dev make python-pip libpq-dev
RUN apt-get -y install git python-dev make python-pip libpq-dev
RUN apt-get -y install postgresql postgresql-contrib
CMD mkdir -p /app && chown -R postgres:postgres /app
# Add the application code to the image
ADD . /root/
ADD . /app/
# Set a working directory
WORKDIR /root/
WORKDIR /app/
# Build the application
RUN make install
RUN python manage.py migrate --settings=config.local
RUN pip install -r requirements.txt --upgrade
# Build the v2 database
RUN printf "execfile('data/v2/build.py')" | python manage.py shell --settings=config.local
# Start postgres database and use it while it is running in the container
# Create the default db user (ash)
RUN sudo -u postgres service postgresql start && \
sudo -u postgres psql --command "CREATE USER ash WITH PASSWORD 'pokemon'" && \
sudo -u postgres createdb -O ash pokeapi && \
python manage.py migrate --settings=config.docker && \
printf "from data.v2.build import build_all; build_all()" | python manage.py shell --settings=config.docker
# Expose the app and serve the API.
EXPOSE 8000
CMD python manage.py runserver --settings=config.local 0.0.0.0:8000
CMD service postgresql start && python manage.py runserver --settings=config.docker 0.0.0.0:8000

16
config/docker.py Executable file
View file

@ -0,0 +1,16 @@
# Docker settings
from .settings import *
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'pokeapi',
'USER': 'ash',
'PASSWORD': 'pokemon',
'HOST': 'localhost',
'PORT': '',
}
}
DEBUG = True
TASTYPIE_FULL_DEBUG = True