Initial commit
This commit is contained in:
commit
299ff31781
3
.env
Normal file
3
.env
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
POSTGRES_USER=sahana
|
||||||
|
POSTGRES_PASSWORD=sahana
|
||||||
|
POSTGRES_DB=sahana
|
2
README.rst
Normal file
2
README.rst
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Sahana Eden
|
||||||
|
===========
|
40
docker-compose.yml
Normal file
40
docker-compose.yml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
|
||||||
|
sahana:
|
||||||
|
build: sahana
|
||||||
|
image: sahana:1.0.3-220306
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- sahana-postgres
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
expose:
|
||||||
|
- 8080
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
volumes:
|
||||||
|
- sahana_models:/srv/web2py/applications/eden/models
|
||||||
|
- sahana_databases:/srv/web2py/applications/eden/databases
|
||||||
|
- sahana_errors:/srv/web2py/applications/eden/errors
|
||||||
|
- sahana_sessions:/srv/web2py/applications/eden/sessions
|
||||||
|
- sahana_uploads:/srv/web2py/applications/eden/uploads
|
||||||
|
|
||||||
|
sahana-postgres:
|
||||||
|
image: postgis/postgis:13-3.2-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER
|
||||||
|
- POSTGRES_PASSWORD
|
||||||
|
- POSTGRES_DB
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
sahana_models:
|
||||||
|
sahana_databases:
|
||||||
|
sahana_errors:
|
||||||
|
sahana_sessions:
|
||||||
|
sahana_uploads:
|
||||||
|
postgres_data:
|
46
sahana/Dockerfile
Normal file
46
sahana/Dockerfile
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
FROM docker.io/alpine:3.15
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
# Install OS and python runtime dependencies
|
||||||
|
apk --no-cache add curl libbz2 libgcc libstdc++ libxml2 libxslt ncurses-libs openssl pcre readline s6 xz-libs && \
|
||||||
|
apk --no-cache add python3 py3-pip py3-wheel && \
|
||||||
|
ln -s /usr/bin/python3 /usr/bin/python
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
# Install Sahana Eden runtime dependencies
|
||||||
|
apk --no-cache add ansible at geos nginx py3-dateutil py3-gdal py3-lxml py3-numpy py3-pillow py3-psycopg2 py3-requests py3-sgmllib3k py3-yaml uwsgi-python3 sudo
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
# Install build dependencies
|
||||||
|
apk --no-cache add --virtual .deps build-base freetype-dev git py3-numpy-dev python3-dev ttf-dejavu && \
|
||||||
|
# Install web2py 2.21.2
|
||||||
|
# See https://github.com/sahana/eden/blob/master/tests/travis/install_web2py.sh
|
||||||
|
git clone --recursive git://github.com/web2py/web2py.git /srv/web2py && \
|
||||||
|
git -C /srv/web2py reset --hard 31905858b && \
|
||||||
|
git -C /srv/web2py submodule update --recursive && \
|
||||||
|
# Install Sahana
|
||||||
|
git clone --recursive --depth 1 https://github.com/sahana/eden.git /srv/web2py/applications/eden && \
|
||||||
|
# Install python dependencies, exclude old or unnecessary ones
|
||||||
|
# - boto - Needed for setup on AWS
|
||||||
|
# - PyRTF - Ceased to exist
|
||||||
|
# - openstacksdk - Needed for setup on OpenStack
|
||||||
|
sed -i 's/^boto/#boto/' /srv/web2py/applications/eden/optional_requirements.txt && \
|
||||||
|
sed -i 's/^PyRTF/#PyRTF/' /srv/web2py/applications/eden/optional_requirements.txt && \
|
||||||
|
sed -i 's/^openstacksdk/#openstacksdk/' /srv/web2py/applications/eden/optional_requirements.txt && \
|
||||||
|
pip3 install -r /srv/web2py/applications/eden/optional_requirements.txt && \
|
||||||
|
# Hackfix paths for ansible and other modules with hardcoded paths
|
||||||
|
ln -s /srv/web2py /home/prod && \
|
||||||
|
# Create OS user
|
||||||
|
addgroup -S -g 8080 sahana && \
|
||||||
|
adduser -S -u 8080 -h /srv/web2py -s /bin/false -g sahana -G sahana sahana && \
|
||||||
|
chown -R sahana:sahana /srv/web2py && \
|
||||||
|
# Cleanup
|
||||||
|
apk --no-cache del .deps && \
|
||||||
|
find /srv/web2py -name '.git*' -exec rm -rf {} + && \
|
||||||
|
rm -r /root/.cache
|
||||||
|
|
||||||
|
COPY image.d /
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
EXPOSE 8080
|
||||||
|
VOLUME ["/srv/web2py/applications/eden/models", "/srv/web2py/applications/eden/databases", "/srv/web2py/applications/eden/errors", "/srv/web2py/applications/eden/sessions", "/srv/web2py/applications/eden/uploads"]
|
14
sahana/image.d/entrypoint.sh
Executable file
14
sahana/image.d/entrypoint.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$*" != "" ]; then
|
||||||
|
exec $@
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting Sahana Eden..."
|
||||||
|
|
||||||
|
# Upgrade database
|
||||||
|
/usr/local/bin/migrate norestart
|
||||||
|
|
||||||
|
# Exec into s6 supervisor
|
||||||
|
exec /bin/s6-svscan /etc/services.d
|
40
sahana/image.d/etc/nginx/nginx.conf
Normal file
40
sahana/image.d/etc/nginx/nginx.conf
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
user nginx;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
worker_processes 1;
|
||||||
|
error_log /dev/stderr warn;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
access_log off;
|
||||||
|
server_tokens off;
|
||||||
|
client_max_body_size 100m;
|
||||||
|
sendfile on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
send_timeout 300;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 8080;
|
||||||
|
|
||||||
|
location /eden {
|
||||||
|
uwsgi_pass unix:///run/uwsgi;
|
||||||
|
uwsgi_read_timeout 300s;
|
||||||
|
uwsgi_send_timeout 300s;
|
||||||
|
include uwsgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* /eden/static {
|
||||||
|
root /srv/web2py/applications;
|
||||||
|
expires max;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = / {
|
||||||
|
return 301 https://$http_x_forwarded_host/eden/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
sahana/image.d/etc/services.d/.s6-svscan/finish
Executable file
5
sahana/image.d/etc/services.d/.s6-svscan/finish
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/execlineb -P
|
||||||
|
|
||||||
|
foreground { s6-svwait -d -t 3000 atd }
|
||||||
|
foreground { s6-svwait -d -t 3000 nginx }
|
||||||
|
foreground { s6-svwait -d -t 3000 uwsgi }
|
3
sahana/image.d/etc/services.d/atd/run
Executable file
3
sahana/image.d/etc/services.d/atd/run
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/execlineb -P
|
||||||
|
|
||||||
|
atd -f
|
3
sahana/image.d/etc/services.d/nginx/run
Executable file
3
sahana/image.d/etc/services.d/nginx/run
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/execlineb -P
|
||||||
|
|
||||||
|
nginx -g "daemon off;"
|
1
sahana/image.d/etc/services.d/uwsgi/down-signal
Normal file
1
sahana/image.d/etc/services.d/uwsgi/down-signal
Normal file
@ -0,0 +1 @@
|
|||||||
|
SIGINT
|
3
sahana/image.d/etc/services.d/uwsgi/run
Executable file
3
sahana/image.d/etc/services.d/uwsgi/run
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/execlineb -P
|
||||||
|
|
||||||
|
uwsgi --ini /etc/uwsgi/uwsgi.conf
|
1
sahana/image.d/etc/sudoers.d/sahana
Normal file
1
sahana/image.d/etc/sudoers.d/sahana
Normal file
@ -0,0 +1 @@
|
|||||||
|
sahana ALL=(ALL) NOPASSWD:ALL
|
22
sahana/image.d/etc/uwsgi/uwsgi.conf
Normal file
22
sahana/image.d/etc/uwsgi/uwsgi.conf
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[uwsgi]
|
||||||
|
uid = sahana
|
||||||
|
gid = sahana
|
||||||
|
chdir = /srv/web2py
|
||||||
|
|
||||||
|
plugin = python
|
||||||
|
enable-threads = 1
|
||||||
|
module = wsgihandler
|
||||||
|
|
||||||
|
socket = /run/uwsgi
|
||||||
|
chown-socket = nginx:nginx
|
||||||
|
|
||||||
|
cheaper = 1
|
||||||
|
cheaper-algo = spare
|
||||||
|
cheaper-initial = 1
|
||||||
|
cheaper-step = 1
|
||||||
|
workers = 8
|
||||||
|
idle = 600
|
||||||
|
harakiri = 300
|
||||||
|
|
||||||
|
mule = run_scheduler.py
|
||||||
|
cron = 10 -1 -1 -1 -1 python web2py.py -Q -S eden -M -R scripts/sessions2trash.py -A -o
|
10
sahana/image.d/srv/web2py/routes.py
Normal file
10
sahana/image.d/srv/web2py/routes.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
default_application = 'eden'
|
||||||
|
default_controller = 'default'
|
||||||
|
default_function = 'index'
|
||||||
|
routes_onerror = [
|
||||||
|
('eden/400', '!'),
|
||||||
|
('eden/401', '!'),
|
||||||
|
('eden/*', '/eden/errors/index'),
|
||||||
|
('*/*', '/eden/errors/index'),
|
||||||
|
]
|
6
sahana/image.d/srv/web2py/run_scheduler.py
Normal file
6
sahana/image.d/srv/web2py/run_scheduler.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from gluon.shell import run
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run('eden', True, True, None, False, 'from gluon import current; current._scheduler.loop()')
|
15
sahana/image.d/usr/local/bin/migrate
Executable file
15
sahana/image.d/usr/local/bin/migrate
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is a compatible rewrite of https://github.com/sahana/eden_deploy/blob/master/roles/common/files/migrate specific for Alpine s6-based container
|
||||||
|
|
||||||
|
# Migrate database
|
||||||
|
cd /srv/web2py
|
||||||
|
sed -i 's/settings.base.migrate = False/settings.base.migrate = True/g' applications/eden/models/000_config.py
|
||||||
|
rm -rf applications/eden/compiled
|
||||||
|
sudo -u sahana -- ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
|
||||||
|
sed -i 's/settings.base.migrate = True/settings.base.migrate = False/g' applications/eden/models/000_config.py
|
||||||
|
|
||||||
|
# Restart uwsgi
|
||||||
|
if [ "$1" != "norestart" ]; then
|
||||||
|
s6-svc -t /etc/services.d/uwsgi
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user