Skip to content

Commit

Permalink
Initial WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbelesky committed Feb 3, 2017
1 parent 3a03e29 commit 573891c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ data/*
!data/presets/
!data/fixtures/

# Docker
dbdata

# Docs
docs/site/
issues-*.html
Expand Down
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Docker file lists all the commands needed to setup a fresh linux instance to
# run the application specified. docker-compose does not use this.

# Grab a python image
FROM python:3.6

# Just needed for all things python
ENV PYTHONUNBUFFERED 1

# Setup Node/NPM
RUN apt-get update && apt-get install curl
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash
RUN apt-get install -y nodejs

# Copy all our files into the baseimage and cd to that directory
RUN mkdir /tcd
WORKDIR /tcd
ADD . /tcd/ # Can this be skipped? Takes ages
COPY ./tabbycat/local_settings.example /tcd/tabbycat/local_settings.py

# Install our python requirements
RUN pip install -r ./requirements_common.txt

# Install our node requirements
RUN npm install

# This needs to happen else sass gets angry
RUN npm rebuild node-sass

# Migrate our database
# RUN python ./tabbycat/manage.py migrate --noinput

# Run server
EXPOSE 8000
# RUN python ./tabbycat/manage.py runserver
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Docker-compose is a way to run multiple containers at once and connect them
# This sets up and runs postgres, the django dev server

# Initial setup with
# $ docker-compose up
# Can run management commands with
# $ docker-compose run web /code/manage.py whatever

version: '2'
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: password
volumes:
- ./dbdata:/var/lib/postgresql/data
web:
# Hack to wait until Postgres is up before running things
command: bash -c "while ! nc -w 1 -z db 5432; do sleep 0.1; done; ./tabbycat/manage.py migrate; while :; do ./tabbycat/manage.py runserver_plus 0.0.0.0:8000; sleep 1; done"
image: django
build: .
volumes:
- .:/code
depends_on:
- db
environment:
IN_DOCKER: 1
6 changes: 3 additions & 3 deletions tabbycat/local_settings.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ SECRET_KEY = '#2q43u&tp4((4&m3i8v%w-6z6pp7m(v0-6@w@i!j5n)n15epwc'
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.postgresql_psycopg2',
'NAME' : '',
'USER' : '',
'NAME' : 'postgres',
'USER' : 'postgres',
'PASSWORD': '',
'HOST': 'localhost',
'HOST': 'db',
'PORT': '5432',
'CONN_MAX_AGE': 600,
}
Expand Down

0 comments on commit 573891c

Please sign in to comment.