mirror of
https://github.com/umap-project/umap.git
synced 2025-05-05 06:01:48 +02:00
Closes #1: Add docker environment for development and production
This commit is contained in:
parent
7f868af5e5
commit
6a33ffc480
11 changed files with 117 additions and 32 deletions
6
.dockerignore
Normal file
6
.dockerignore
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.vscode/
|
||||||
|
.venv/
|
||||||
|
build/
|
||||||
|
static/
|
||||||
|
umap_project.egg-info/
|
||||||
|
data/
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -8,6 +8,8 @@ node_modules/*
|
||||||
umap/static/umap/vendors
|
umap/static/umap/vendors
|
||||||
site/*
|
site/*
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
|
static/
|
||||||
|
uploads/
|
||||||
|
|
||||||
### Python ###
|
### Python ###
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
|
@ -18,3 +20,6 @@ build/
|
||||||
dist/
|
dist/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
|
|
||||||
|
.env
|
||||||
|
.venv/
|
||||||
|
|
||||||
|
|
24
.vscode/launch.json
vendored
Normal file
24
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Python: Remote Attach",
|
||||||
|
"type": "python",
|
||||||
|
"request": "attach",
|
||||||
|
"connect": {
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 5678
|
||||||
|
},
|
||||||
|
"pathMappings": [
|
||||||
|
{
|
||||||
|
"localRoot": "${workspaceFolder}/umap/",
|
||||||
|
"remoteRoot": "/srv/app/umap/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"justMyCode": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
47
Dockerfile
47
Dockerfile
|
@ -1,27 +1,13 @@
|
||||||
FROM node:18 AS vendors
|
FROM node:18 AS vendors
|
||||||
|
|
||||||
COPY . /srv/umap
|
COPY . /srv/app
|
||||||
|
|
||||||
WORKDIR /srv/umap
|
WORKDIR /srv/app
|
||||||
|
|
||||||
RUN make installjs
|
RUN make installjs
|
||||||
|
|
||||||
RUN make vendors
|
RUN make vendors
|
||||||
|
|
||||||
FROM python:3.8-slim
|
FROM python:3.8-slim as app_python
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1 \
|
|
||||||
UMAP_SETTINGS=/srv/umap/umap/settings/docker.py \
|
|
||||||
PORT=8000
|
|
||||||
|
|
||||||
RUN mkdir -p /srv/umap/data && \
|
|
||||||
mkdir -p /srv/umap/uploads
|
|
||||||
|
|
||||||
COPY . /srv/umap
|
|
||||||
|
|
||||||
COPY --from=vendors /srv/umap/umap/static/umap/vendors /srv/umap/umap/static/umap/vendors
|
|
||||||
|
|
||||||
WORKDIR /srv/umap
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
|
@ -42,10 +28,21 @@ RUN apt-get update && \
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
libfreetype6-dev \
|
libfreetype6-dev \
|
||||||
liblcms2-dev \
|
liblcms2-dev \
|
||||||
libwebp-dev \
|
libwebp-dev
|
||||||
&& \
|
|
||||||
pip install --no-cache -r requirements-docker.txt && pip install . && \
|
ENV PYTHONUNBUFFERED=1 \
|
||||||
apt-get remove -y \
|
UMAP_SETTINGS=/srv/app/umap/settings/docker.py \
|
||||||
|
PORT=8000
|
||||||
|
|
||||||
|
COPY . /srv/app
|
||||||
|
RUN mkdir -p /srv/app/data && \
|
||||||
|
mkdir -p /srv/app/uploads
|
||||||
|
COPY --from=vendors /srv/app/umap/static/umap/vendors /srv/app/umap/static/umap/vendors
|
||||||
|
|
||||||
|
WORKDIR /srv/app
|
||||||
|
|
||||||
|
RUN pip install --no-cache -r requirements-docker.txt && pip install .
|
||||||
|
RUN apt-get remove -y \
|
||||||
binutils \
|
binutils \
|
||||||
libproj-dev \
|
libproj-dev \
|
||||||
libffi-dev \
|
libffi-dev \
|
||||||
|
@ -64,4 +61,10 @@ EXPOSE 8000
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||||
|
|
||||||
CMD ["/srv/umap/docker-entrypoint.sh"]
|
CMD ["/srv/app/docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
FROM app_python as app_python_debug
|
||||||
|
|
||||||
|
WORKDIR /srv/app
|
||||||
|
|
||||||
|
RUN pip install debugpy==1.6.7
|
||||||
|
|
14
docker-compose.override.yml
Normal file
14
docker-compose.override.yml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
target: app_python_debug
|
||||||
|
environment:
|
||||||
|
PYTHON_DEBUG: True
|
||||||
|
volumes:
|
||||||
|
- ./umap:/srv/app/umap
|
||||||
|
ports:
|
||||||
|
- 8000:8000
|
||||||
|
- 5678:5678
|
28
docker-compose.yml
Normal file
28
docker-compose.yml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
version: '2'
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgis/postgis:14-3.2
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/lib/postgresql/data
|
||||||
|
redis:
|
||||||
|
image: redis:latest
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: app_python
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgis://postgres:postgres@postgres/postgres
|
||||||
|
REDIS_URL: redis://redis:6379/0
|
||||||
|
SECRET_KEY: some-long-and-weirdly-unrandom-secret-key
|
||||||
|
ALLOWED_HOSTS: "*"
|
||||||
|
SITE_URL: http://localhost:8000/
|
||||||
|
LEAFLET_STORAGE_ALLOW_ANONYMOUS: true
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
volumes:
|
||||||
|
- $PWD:/srv/umap
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
|
@ -27,5 +27,9 @@ umap collectstatic --noinput
|
||||||
#umap storagei18n
|
#umap storagei18n
|
||||||
# compress static files
|
# compress static files
|
||||||
umap compress
|
umap compress
|
||||||
# run uWSGI
|
|
||||||
exec uwsgi --ini uwsgi.ini
|
if [ "$PYTHON_DEBUG" = true ] ; then
|
||||||
|
python -m debugpy --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8000 --nothreading --noreload
|
||||||
|
else
|
||||||
|
exec uwsgi --ini uwsgi.ini
|
||||||
|
fi
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
django-environ==0.4.1
|
django-environ==0.4.1
|
||||||
django-redis==4.7.0
|
django-redis==5.2.0
|
||||||
uwsgi==2.0.14
|
uwsgi==2.0.21
|
||||||
|
|
|
@ -12,5 +12,6 @@ DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'NAME': 'umap',
|
'NAME': 'umap',
|
||||||
|
'SECRET_KEY': 'some-long-and-weirdly-unrandom-secret-key',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ env = environ.Env()
|
||||||
|
|
||||||
SECRET_KEY = env('SECRET_KEY')
|
SECRET_KEY = env('SECRET_KEY')
|
||||||
INTERNAL_IPS = env.list('INTERNAL_IPS', default='127.0.0.1')
|
INTERNAL_IPS = env.list('INTERNAL_IPS', default='127.0.0.1')
|
||||||
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default='*')
|
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['*'])
|
||||||
|
|
||||||
DEBUG = env.bool('DEBUG', default=False)
|
DEBUG = env.bool('PYTHON_DEBUG', default=False)
|
||||||
|
|
||||||
ADMIN_EMAILS = env.list('ADMIN_EMAIL', default='')
|
ADMIN_EMAILS = env.list('ADMIN_EMAIL', default='')
|
||||||
ADMINS = [(email, email) for email in ADMIN_EMAILS]
|
ADMINS = [(email, email) for email in ADMIN_EMAILS]
|
||||||
|
@ -111,10 +111,10 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
UMAP_USE_UNACCENT = False
|
UMAP_USE_UNACCENT = False
|
||||||
|
|
||||||
# For static deployment
|
# For static deployment
|
||||||
STATIC_ROOT = '/srv/umap/static'
|
STATIC_ROOT = '/srv/app/static'
|
||||||
|
|
||||||
# For users' statics (geojson mainly)
|
# For users' statics (geojson mainly)
|
||||||
MEDIA_ROOT = '/srv/umap/uploads'
|
MEDIA_ROOT = '/srv/app/uploads'
|
||||||
|
|
||||||
# Default map location for new maps
|
# Default map location for new maps
|
||||||
LEAFLET_LONGITUDE = env.int('LEAFLET_LONGITUDE', default=2)
|
LEAFLET_LONGITUDE = env.int('LEAFLET_LONGITUDE', default=2)
|
||||||
|
|
|
@ -6,5 +6,5 @@ vacuum = True
|
||||||
max-requests = 5000
|
max-requests = 5000
|
||||||
processes = 4
|
processes = 4
|
||||||
enable-threads = true
|
enable-threads = true
|
||||||
static-map = /static=/srv/umap/static
|
static-map = /static=/srv/app/static
|
||||||
static-map = /uploads=/srv/umap/uploads
|
static-map = /uploads=/srv/app/uploads
|
||||||
|
|
Loading…
Reference in a new issue