Skip to content

Commit

Permalink
Initial community edition release
Browse files Browse the repository at this point in the history
  • Loading branch information
varmar05 authored and wonder-sk committed Jun 10, 2021
1 parent 5ecdb11 commit c382eaf
Show file tree
Hide file tree
Showing 282 changed files with 34,247 additions and 1 deletion.
81 changes: 81 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# exclude unnecessary dirs/files
projects
web-app/node_modules
server/pytest.ini
server/test*
server/coverage*
server/celerybeat*

.git
.travis.yaml
.swagger-codegen-ignore
README.md
tox.ini
git_push.sh
test-requirements.txt
setup.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# 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/
venv/
.python-version

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

#Ipython Notebook
.ipynb_checkpoints
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# demo data
logs/
projects/

*.log
.DS_Store
.idea

.mergin.env
64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# multistage build requires at least docker-ce 17.06
FROM ubuntu:18.04 AS builder
MAINTAINER Martin Varga "[email protected]"

# use some custom packages that are too obsolete in official repo
# use node.js from nodesource PPA (for npm packages)
RUN apt-get update -y && \
apt-get install -y --no-install-recommends\
python \
python-pip \
gnupg \
wget && \
wget https://deb.nodesource.com/setup_10.x --no-check-certificate && \
bash setup_10.x && \
apt-get install -y --no-install-recommends\
nodejs && \
rm -rf /var/lib/apt/lists/*

# server files will be merely copied from builder
COPY ./server /mergin/server

# build frontend app
COPY ./web-app /mergin/web-app
WORKDIR /mergin/web-app
RUN npm install
RUN npm run build

CMD echo 'Build is finished.'

FROM ubuntu:18.04
MAINTAINER Martin Varga "[email protected]"

RUN apt-get update -y && \
apt-get install -y --no-install-recommends\
musl-dev \
python3 \
python3-pip \
python3-setuptools \
iputils-ping \
gcc build-essential binutils cmake extra-cmake-modules && \
rm -rf /var/lib/apt/lists/*


# needed for geodiff
RUN pip3 install --upgrade pip
RUN ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1

# create mergin user to run container with
RUN groupadd -r mergin -g 901
RUN groupadd -r mergin-family -g 999
RUN useradd -u 901 -r --home-dir /app --create-home -g mergin -G mergin-family -s /sbin/nologin mergin

WORKDIR /app
COPY --from=builder /mergin/server .

RUN pip3 install pipenv==2018.11.26
# for locale check this http://click.pocoo.org/5/python3/
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN pipenv install --system --deploy

USER mergin
COPY ./entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,58 @@ https://public.cloudmergin.com/

Store and track changes to your geo-data

**This repository does not contain source code of Mergin project - it is used for tracking of feature requests and issues reported by Mergin users.**
## Running with Docker
Adjust configuration, e.g. replace 'fixme' entries:
```shell
$ cp mergin.env.template mergin.env
```

Run with docker compose:
```shell
$ export TAG=2021.6 # specify version
$ docker-compose up
$ docker exec -it mergin-server flask init-db
$ docker exec -it mergin-server flask add-user admin topsecret --is-admin --email [email protected]
$ sudo chown -R 901:999 ./projects/
$ sudo chmod g+s ./projects/
```
Projects are saved locally in `./projects` folder.

## Running locally (for dev)
Install dependencies and run services:

```shell
$ docker run -d --rm --name mergin_db -p 5002:5432 -e POSTGRES_PASSWORD=postgres postgres:10
$ docker run -d --rm --name redis -p 6379:6379 redis
```

### Server
```shell
$ pip3 install pipenv
$ cd server
$ pipenv install --dev --three
$ pipenv run flask init-db
$ pipenv run flask add-user admin topsecret --is-admin --email [email protected]
$ pipenv run celery worker -A src.run_celery.celery --loglevel=info &
$ pipenv run flask run # run dev server on port 5000
```

### Web app
```shell
$ sudo apt install nodejs
$ cd web-app
$ npm install
$ npm run serve
```
and open your browser to here:
```
http://localhost:8080
```

## Running tests
To launch the unit tests run:
```shell
$ docker run -d --rm --name testing_pg -p 5435:5432 -e POSTGRES_PASSWORD=postgres postgres:10
$ cd server
$ pipenv run pytest --cov-report html --cov=src test
```
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.7"

services:
db:
image: postgres:10
container_name: mergin-db
ports:
- 5432:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres

server:
image: mergin:${TAG}
build:
context: .
dockerfile: Dockerfile
container_name: mergin-server
volumes:
- ./projects:/data # map data dir to host
env_file:
- mergin.env
environment:
- VERSION=${TAG}
ports:
- 5000:5000
depends_on:
- db
links:
- db
redis:
image: redis
container_name: mergin-redis
ports:
- 6379:6379
11 changes: 11 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# make sure all files created by gunicorn (mergin server) have proper permissions
umask 0027

# We store a base config in config.py and override things as needed
# using the environment variable GUNICORN_CMD_ARGS.

/bin/bash -c "celery beat -A src.celery --loglevel=info &"
/bin/bash -c "celery worker -A src.run_celery.celery --loglevel=info &"
/bin/bash -c "gunicorn --config config.py mergin:application"

35 changes: 35 additions & 0 deletions mergin.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
SWAGGER_UI=0
SECRET_KEY=fixme
SECURITY_PASSWORD_SALT=fixme
LOCAL_PROJECTS=/data
MAINTENANCE_FILE=/data/MAINTENANCE
USER_SELF_REGISTRATION=1
USE_X_ACCEL=0
GEODIFF_LOGGER_LEVEL=2
TEMP_DIR=/data/tmp
MERGIN_TESTING=0
MAX_CHUNK_SIZE=10485760 # 10 MB
TEMP_EXPIRATION=7
DELETED_PROJECT_EXPIRATION=7
CLOSED_ACCOUNT_EXPIRATION=1
DEFAULT_STORAGE_SIZE=104857600 # 100 MB
# database
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=172.17.0.1
DB_PORT=5432
DB_APPLICATION_NAME=mergin
# SMTP settings
MAIL_SUPPRESS_SEND=1 # set to 0 in production
MAIL_SERVER=fixme
MAIL_DEFAULT_SENDER=fixme
MAIL_USERNAME=fixme
# for email templates
MERGIN_BASE_URL=your-server-url
MERGIN_LOGO_URL=""
CONTACT_EMAIL=fix-me
# integration with slack
SLACK_HOOK_URL=fixme
# integration with celery and redis
CELERY_BROKER_URL="redis://172.17.0.1:6379/0"
CELERY_RESULT_BACKEND="redis://172.17.0.1:6379/0"
18 changes: 18 additions & 0 deletions server/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# .coveragerc to control coverage.py
[run]
omit =
# omit auto-generated files
src/models/base_model_.py
src/encoder.py
src/util.py
src/auth/commands.py
# omit test dir
src/test/*

[report]
exclude_lines =
pragma: no cover
raise NotImplementedError

[html]
directory = coverage_html_report
2 changes: 2 additions & 0 deletions server/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FLASK_APP=commands.py
GEODIFF_LOGGER_LEVEL="2"
Loading

0 comments on commit c382eaf

Please sign in to comment.