Skip to content

Commit

Permalink
Merge pull request #45 from sdslabs/dockerize
Browse files Browse the repository at this point in the history
[WIP] Containerize portfolio
  • Loading branch information
ayanchoudhary authored May 1, 2020
2 parents 782666f + dcf5423 commit ab8ea49
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM python:3.7-stretch

ENV PYTHONBUFFERED 1

RUN apt-get update \
&& apt-get install libexempi3 \
&& mkdir -p /var/log/portfolio.log

WORKDIR /portfolio

# Install Python dependency management tools
RUN pip install --upgrade pip \
&& pip install --upgrade setuptools

# Copy the requirements.txt into the container
COPY settings/requirements-common.txt /portfolio/
COPY settings/dev/requirements-dev.txt /portfolio/

# Install the dependencies system-wide
# TODO: Use build args to avoid installing dev dependencies in production
RUN pip install -r requirements-common.txt
RUN pip install -r requirements-dev.txt
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3"
services:
db:
image: "postgres"
container_name: "portfolio-postgres"
environment:
POSTGRES_DB: "portfolio"
POSTGRES_PASSWORD: "portfolio"
POSTGRES_USER: "portfolio"
POSTGRES_HOST: "0.0.0.0"

ports:
- "5432:5432"
volumes:
- ~/_postgresql_data:/var/lib/postgresql/data

web:
build: ./
image: portfolio
command: bash -c 'python manage.py migrate --settings settings.dev.settings &&
python manage.py runserver --settings settings.dev.settings'
container_name: portfolio
volumes:
- ".:/portfolio:rw"
ports:
- "8000:8000"
depends_on:
- db
extra_hosts:
- "localhost:127.0.0.1"
environment:
DJANGO_DATABASE_NAME: "portfolio"
DJANGO_DATABASE_USER: "portfolio"
DJANGO_DATABASE_PASSWORD: "portfolio"
DJANGO_DATABASE_HOST: "db"
PYTHONUNBUFFERED: "0"
DJANGO_DEBUG_ENABLED: "True"
stdin_open: true
tty: true
1 change: 0 additions & 1 deletion settings/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions settings/dev/settings.sample.py → settings/dev/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
'NAME': 'portfolio',
'USER': 'portfolio',
'PASSWORD': 'portfolio',
'HOST': '127.0.0.1',
'HOST': 'db',
'PORT': '5432',
}
}

CACHES['default']['LOCATION'] = os.environ.get('MEMCACHED_LOCATION', '127.0.0.1:11211') # noqa: ignore=F405
CACHES['default']['LOCATION'] = os.environ.get('MEMCACHED_LOCATION', 'db:11211') # noqa: ignore=F405

0 comments on commit ab8ea49

Please sign in to comment.