-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic config copied from eoa2-xmldb repo. ran 'django-admin startproj…
…ect'
- Loading branch information
EsGeh
authored and
EsGeh
committed
Nov 11, 2019
0 parents
commit 620e0e5
Showing
21 changed files
with
834 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/runtime_data | ||
/scripts | ||
/env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
|
||
# manual entries: | ||
/dependencies/ | ||
/runtime_data/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM python:3 | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
ENV SHELL /bin/bash | ||
|
||
# ------------------------------------------ | ||
# install necessary packages via apt-get: | ||
# ------------------------------------------ | ||
# RUN apt-get update && \ | ||
# apt-get install -y --no-install-recommends \ | ||
# libsaxonhe-java | ||
|
||
# ------------------------------------------ | ||
# install python dependencies: | ||
# ------------------------------------------ | ||
COPY requirements.txt "$INSTALL_DIR/" | ||
RUN pip install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
version: '3.7' | ||
|
||
services: | ||
|
||
db: | ||
image: postgres:11 | ||
volumes: | ||
- ./${DATABASE_DATA_DIR}:${DATABASE_DATA_DIR_IN_CONTAINER} | ||
container_name: ${DB_CONTAINER} | ||
user: ${USER}:${GROUP} | ||
environment: | ||
# postgres data dir | ||
- PGDATA=${DATABASE_DATA_DIR_IN_CONTAINER} | ||
# postgres user | ||
- POSTGRES_USER=postgres | ||
|
||
# eoa-django | ||
webserver: | ||
depends_on: | ||
- db | ||
build: . | ||
image: ${WEB_SERVER_IMAGE} | ||
container_name: ${WEB_SERVER_CONTAINER} | ||
command: python3 manage.py runserver 0.0.0.0:8000 | ||
volumes: | ||
- ./${SRC_DIR}:${SRC_DIR_IN_CONTAINER} | ||
- ./${RES_DIR_RUNTIME}:${RES_DIR_IN_CONTAINER} | ||
working_dir: ${SRC_DIR_IN_CONTAINER} | ||
environment: | ||
- INSTALL_DIR=${SRC_DIR_IN_CONTAINER} | ||
- RES_DIR=${RES_DIR_IN_CONTAINER} | ||
ports: | ||
- "8000:8000" | ||
user: ${USER}:${GROUP} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Django==2.2 | ||
psycopg2-binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../dependencies/webdesign_platform/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[config] | ||
|
||
################################################### | ||
# container names: | ||
WEB_SERVER_CONTAINER=eoa_1_5_webserver | ||
DB_CONTAINER=db | ||
WEB_SERVER_IMAGE=eoa_1_5_webserver | ||
|
||
################################################### | ||
# volumes: | ||
|
||
RUNTIME_DIR=runtime_data | ||
|
||
DATABASE_DATA_DIR=${RUNTIME_DIR}/postgres_data | ||
DATABASE_DATA_DIR_IN_CONTAINER=/eoa/postgres_data | ||
|
||
SRC_DIR=src | ||
SRC_DIR_IN_CONTAINER=/eoa/server | ||
|
||
RES_DIR=res | ||
RES_DIR_RUNTIME=${RUNTIME_DIR}/res.rt | ||
RES_DIR_IN_CONTAINER=/eoa/res | ||
|
||
################################################### | ||
# user and group: | ||
# USER=$(id -u) | ||
# GROUP=$(id -g) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/fish | ||
|
||
if not set -q SCRIPT_DIR | ||
echo "ERROR in (status -m): \$SCRIPT_DIR is undefined!" | ||
exit 1 | ||
end | ||
set BASE_DIR "$SCRIPT_DIR/.." | ||
|
||
####################################### | ||
# actual script | ||
####################################### | ||
|
||
set RUNTIME_DIR "runtime_data" | ||
|
||
################################################### | ||
# export all these variables, so | ||
# they can be referenced in the docker-compose.yaml | ||
################################################### | ||
|
||
# convert bash syntax to fish syntax: | ||
set commands (cat ./scripts/config/env.conf | grep -E --invert-match '^#|^[[:space:]]*$' | sed 's/^\(.*\)=\(.*\)/set -x \1 \2/' | sed 's/\$(/(/g') | ||
|
||
for cmd in $commands | ||
echo "cmd: $cmd" | ||
eval "$cmd" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
if [[ "$SCRIPT_DIR" == "" ]]; then | ||
echo "ERROR in ./scripts/config/load_env.sh: \$SCRIPT_DIR is undefined!" | ||
exit 1 | ||
fi | ||
BASE_DIR="$SCRIPT_DIR/.." | ||
|
||
####################################### | ||
# actual script | ||
####################################### | ||
|
||
|
||
# these are the default settings used by all scripts: | ||
|
||
RUNTIME_DIR=runtime_data | ||
|
||
################################################### | ||
# export all these variables, so | ||
# they can be referenced in the docker-compose.yaml | ||
################################################### | ||
set -a | ||
source $SCRIPT_DIR/config/env.conf | ||
set -a | ||
# (stop exporting variables) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from utils.settings import BASE_DIR, load_config | ||
from utils.functions import exec_in_container | ||
|
||
from pathlib import Path | ||
import os | ||
|
||
if __name__ == '__main__': | ||
|
||
from argparse import ArgumentParser | ||
|
||
config = load_config() | ||
|
||
parser = ArgumentParser( | ||
description="open bash to the container, optionally exec CMD there" | ||
) | ||
parser.add_argument( | ||
"CMD", | ||
nargs='*', | ||
) | ||
args = parser.parse_args() | ||
|
||
CMDS= \ | ||
(vars(args)['CMD']) | ||
|
||
print( CMDS ) | ||
|
||
exec_in_container( | ||
*CMDS, | ||
env=config | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from utils.settings import BASE_DIR, load_config | ||
|
||
from pathlib import Path | ||
import shutil | ||
import os | ||
|
||
def rm_dirs( config ): | ||
path = Path( BASE_DIR, config['RUNTIME_DIR'] ) | ||
print( "removing dir '{}'".format( path ) ) | ||
shutil.rmtree( | ||
path, | ||
ignore_errors=True | ||
) | ||
# os.system('rm -rf "{}"'.format( path )) | ||
|
||
def rm_docker_env_file( config ): | ||
path = Path( | ||
BASE_DIR / ".env" | ||
) | ||
print( "removing '{}'".format( path ) ) | ||
path.unlink() | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
from argparse import ArgumentParser | ||
|
||
config = load_config() | ||
|
||
parser = ArgumentParser( | ||
description="clean up the repository: remove xml database, remove sql database" | ||
) | ||
args = parser.parse_args() | ||
|
||
from stop import stop | ||
|
||
stop( config ) | ||
|
||
rm_dirs( config ) | ||
rm_docker_env_file( config ) |
Oops, something went wrong.