Skip to content

Commit

Permalink
vmc image
Browse files Browse the repository at this point in the history
mwalkowski committed Dec 1, 2019
1 parent 5582aae commit e1f408b
Showing 8 changed files with 239 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# 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/
.idea/
vmc/.idea
.DS_STORE
db.sqllite3

config/vmc/newsletter-prod.yml
vmc/root/opt/app/config/data/init.json
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

#Pycharm
.idea
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
- docker

script: make
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM centos:7.6.1810
ARG VMC_VERSION=1.0.1-alpha
ENV VMC_VERSION=${VMC_VERSION}

ENV TZ=Poland
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY root /

RUN yum install -y epel-release; \
yum -y update;\
yum install -y python36 python36-devel mariadb-devel gcc nginx; \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone; \
pip3.6 install vmcenter==${VMC_VERSION}; \
yum clean all; \
chmod g=u /etc/passwd; \
vmc collectstatic --noinput --clear; \
chmod +x /usr/bin/entrypoint;

EXPOSE 8080

USER 1001

ENTRYPOINT ["entrypoint"]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
v ?= 1.0.1-alpha

all: build

build:
docker build --build-arg VMC_VERSION=$(v) -t vmc .

.PHONY: build
66 changes: 66 additions & 0 deletions root/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
worker_processes auto;
pid /tmp/nginx.pid;
error_log /dev/stdout info;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

client_body_temp_path /tmp/client_temp;
proxy_temp_path /tmp/proxy_temp_path;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;

access_log /dev/stdout;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;


upstream vmc {
server localhost:8001;
}

server {
listen 8080;

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

location / {
proxy_pass http://vmc;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}

location /static/ {
alias /usr/local/lib/python3.6/site-packages/vmc/static/;
}
}
}
22 changes: 22 additions & 0 deletions root/usr/bin/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e

if ! whoami &> /dev/null; then
if [ -w /etc/passwd ]; then
echo "default:x:$(id -u):0:default user:${HOME}:/sbin/nologin" >> /etc/passwd
fi
fi


{
cmd=$1
case $cmd in
admin|monitor|scheduler|worker)
exec vmc $cmd
;;
*)
exec $cmd
;;
esac
}
Empty file added root/usr/share/vmc/.gitkeep
Empty file.

0 comments on commit e1f408b

Please sign in to comment.