Merge pull request #131 from winkidney/feature/docker-change-with-local-settings

Feature:use example file instead of docker-compose.yml / add local settings support
This commit is contained in:
Ji Qu
2018-09-06 20:19:42 +08:00
committed by GitHub
8 changed files with 51 additions and 26 deletions

6
.gitignore vendored
View File

@@ -1,3 +1,9 @@
# local_settings
local_settings.py
# Ignore docker-compose
docker-compose.yml
# Virtualenv/Common
/bin/
/build/

View File

@@ -1,4 +1,4 @@
FROM python:3
FROM python:3.6
ENV PYTHONUNBUFFERED 1
WORKDIR /app
@@ -6,8 +6,3 @@ COPY . /app
RUN pip install pipenv
RUN pipenv install --three --system
RUN python3 manage.py collectstatic --noinput
VOLUME /app/static/media

View File

@@ -49,15 +49,27 @@ Follow the steps below to install Pinry locally or on any server. This
process installs the minimal requirements to run Pinry. For development
requirements and procedures, see testing above.
Current docker configuration will just mount source code directory to
docker app directory and run any codes existed in current git branch,
you may also add "local_settings.py" to customize settings without
changing settings file in `pinry/settings`.
- Install the requirements:
- Docker
- Docker Compose
- Set any custom configuration options you need and run::
cp docker-compose.example.yml docker-compose.yml
# edit docker-compose.yml and change the secret-key,
# don't forget to backup this config file.
docker-compose up -d
- Bootstrap the database::
- If you want to run Pinry with current user in docker::
./start_docker_with_current_user.sh [-d]
- Bootstrap the database(optional)::
docker-compose exec web python3 manage.py migrate --settings=pinry.settings.docker

View File

@@ -0,0 +1,18 @@
version: '3'
services:
web:
build: .
working_dir: /app
command: >
bash -c "python manage.py migrate
&& python3 manage.py collectstatic --noinput
&& gunicorn pinry.wsgi:application -b 0.0.0.0:8000 --timeout 30"
ports:
- "127.0.0.1:2048:8000"
environment:
- SECRET_KEY=CHANGE-ME
user: ${CURRENT_UID}
volumes:
- .:/app
restart: always

View File

@@ -1,19 +0,0 @@
version: '3'
services:
db:
image: postgres
web:
build: .
command: gunicorn pinry.wsgi:application -b 0.0.0.0:80 --timeout 30 --log-file -
ports:
- "80:80"
depends_on:
- db
environment:
- SECRET_KEY=CHANGE-ME
volumes:
- media:/app/static/media
volumes:
media:

View File

@@ -19,3 +19,8 @@ DATABASES = {
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
try:
from .local_settings import *
except ImportError:
pass

View File

@@ -22,3 +22,8 @@ DATABASES = {
'PORT': 5432,
}
}
try:
from .local_settings import *
except ImportError:
pass

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
_CURRENT_UID=$(id -u):$(id -g)
sudo CURRENT_UID=${_CURRENT_UID} docker-compose up ${@}