Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize #7

Merged
merged 2 commits into from Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env_db
@@ -0,0 +1,4 @@
POSTGRES_PASSWORD=postgres
POSTGRES_USER=postgres
SHINYAPP_SUPERUSER_PASSWORD=adminpass
SHINYAPP_SUPERUSER_USERNAME=admin
188 changes: 188 additions & 0 deletions .gitignore
@@ -0,0 +1,188 @@
# Created by .ignore support plugin (hsz.mobi)
### R template
# History files
.Rhistory
.Rapp.history

# Session Data files
.RData

# User-specific files
.Ruserdata

# Example code in package build process
*-Ex.R

# Output files from R CMD build
/*.tar.gz

# Output files from R CMD check
/*.Rcheck/

# RStudio files
.Rproj.user/

# produced vignettes
vignettes/*.html
vignettes/*.pdf

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth

# knitr and R markdown default cache directories
*_cache/
/cache/

# Temporary files created by R markdown
*.utf8.md
*.knit.md

# R Environment Variables
.Renviron

# pkgdown site
docs/

# translation temp files
po/*~

### Python template
# 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/
share/python-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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# 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/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

5 changes: 5 additions & 0 deletions Dockerfile-postgis
@@ -0,0 +1,5 @@
FROM kartoza/postgis:12.0

ADD postgres_setup/* /docker-entrypoint-initdb.d/
#ADD dev_dumps /dumps
#ADD sql /docker-entrypoint-sql
15 changes: 15 additions & 0 deletions Dockerfile_R
@@ -0,0 +1,15 @@
FROM rocker/shiny-verse

#update all packages
RUN apt-get update

#upgrade
RUN apt-get upgrade -y

#install additional packages
RUN apt install gpg-agent -y unixodbc apt-utils curl



#copy app to image
COPY shinyapp/ /srv/shiny-server/shiny_app
28 changes: 28 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,28 @@
version: "3.7"
volumes:
pgdata:

services:
r_container:
container_name: r_container
build:
context: "."
dockerfile: Dockerfile_R
ports:
- "3838:3838"
depends_on:
- postgresql

postgresql:
container_name: postgresql
build:
context: "."
dockerfile: "Dockerfile-postgis"
env_file:
- .env_db
ports:
- 5432:5432
volumes:
- pgdata:/var/lib/postgresql/data
restart: always

9 changes: 9 additions & 0 deletions postgis_setup/setup_db.sh
@@ -0,0 +1,9 @@
#!/bin/bash
#echo -e "\nhost all all all peer\nhost all all 127.0.0.1/32 md5" >> "$PGDATA/pg_hba.conf"
#echo "===> Done editing pg_hba.conf"
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER $SHINYAPP_SUPERUSER_USERNAME SUPERUSER PASSWORD '$SHINYAPP_SUPERUSER_PASSWORD';
CREATE DATABASE shapp WITH OWNER $SHINYAPP_SUPERUSER_USERNAME ENCODING 'utf-8';
GRANT ALL PRIVILEGES ON DATABASE shapp to $SHINYAPP_SUPERUSER_USERNAME;
EOSQL
Empty file added shinyapp/README.md
Empty file.