mirror of
https://github.com/pinry/pinry.git
synced 2026-01-15 19:52:06 +01:00
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:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,3 +1,9 @@
|
||||
# local_settings
|
||||
local_settings.py
|
||||
|
||||
# Ignore docker-compose
|
||||
docker-compose.yml
|
||||
|
||||
# Virtualenv/Common
|
||||
/bin/
|
||||
/build/
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
14
README.rst
14
README.rst
@@ -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
|
||||
|
||||
|
||||
18
docker-compose.example.yml
Normal file
18
docker-compose.example.yml
Normal 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
|
||||
@@ -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:
|
||||
@@ -19,3 +19,8 @@ DATABASES = {
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -22,3 +22,8 @@ DATABASES = {
|
||||
'PORT': 5432,
|
||||
}
|
||||
}
|
||||
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
3
start_docker_with_current_user.sh
Executable file
3
start_docker_with_current_user.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
_CURRENT_UID=$(id -u):$(id -g)
|
||||
sudo CURRENT_UID=${_CURRENT_UID} docker-compose up ${@}
|
||||
Reference in New Issue
Block a user