Skip to content

Commit

Permalink
Merge pull request #62 from ecmwf/consolidated
Browse files Browse the repository at this point in the history
merge version 0.9.0
  • Loading branch information
EduardRosert authored Jun 7, 2022
2 parents dcb4d00 + 2c3fdc8 commit 309da2b
Show file tree
Hide file tree
Showing 27 changed files with 1,015 additions and 323 deletions.
Binary file added .DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
.git*
.dockerignore
.env
.s3env
.travis.yml
.vscode
hooks*
Makefile
docker-compose.yml
venv*

28 changes: 28 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# local development server configuration
#

# the path inside the docker container that stores the GRIB and NetCDF data
SKINNYWMS_DATA_PATH=/data/

# the host ip the server should listen on
# set to 0.0.0.0 to listen on all ips
SKINNYWMS_HOST=0.0.0.0

# the http port the flask server listens on
SKINNYWMS_PORT=5000

# enable/disable layer dimension grouping (by elevation)
SKINNYWMS_ENABLE_DIMENSION_GROUPING=0

# flask env to enable auto reload on code changes
FLASK_ENV=development

# # Configure Magics
#MAGPLUS_HOME=/usr/local/lib/python3.6/site-packages/ecmwflibs
#MAGICS_STYLE_PATH=/usr/local/lib/python3.6/site-packages/ecmwflibs/share/magics/styles/ecmwf
MAGICS_STYLES_DEBUG=on

MAGPLUS_DEBUG=on
MAGPLUS_DEV=on
MAGICS_QUIET=
49 changes: 49 additions & 0 deletions .github/workflows/docker-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is a basic workflow to help you get started with Actions

name: Publish Latest Docker

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [ develop ]
# pull_request:
# branches: [ develop ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repo
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: ecmwf/skinnywms:latest

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
54 changes: 54 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This is a basic workflow to help you get started with Actions

name: Publish Tagged Images to DockerHub

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
tags:
- '*'
# pull_request:
# branches: [ develop ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repo
uses: actions/checkout@v2

- name: Set tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: ecmwf/skinnywms:${{ steps.vars.outputs.tag }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ __pycache__/
meta.xml
*.pyc
*&*
venv/
.venv/
skinnywms/testdata/*/*
44 changes: 35 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
# Build image
# Use slim python 3 + Magics image as base
ARG MAGICS_IMAGE=ecmwf/magics:4.2.4
FROM ${MAGICS_IMAGE}
# Use slim python 3 image as base
ARG PYTHON_IMAGE=python:3.8-slim-buster
FROM ${PYTHON_IMAGE}

# Install UWSGI
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
gcc \
build-essential \
libglib2.0 \
&& rm -rf /var/lib/apt/lists/* \
&& pip install uwsgi \
&& apt-get purge -y --auto-remove \
gcc \
build-essential

# Install skinnywms
RUN set -eux \
&& mkdir -p /app/

COPY . /app/skinnywms
RUN pip install /app/skinnywms --no-dependencies
RUN pip install /app/skinnywms

# Install Python run-time dependencies.
COPY requirements.txt /root/
RUN set -ex \
&& pip install -r /root/requirements.txt
ENV SKINNYWMS_HOST=0.0.0.0
ENV SKINNYWMS_PORT=5000
ENV SKINNYWMS_MOUNT=/
ENV SKINNYWMS_DATA_PATH=
ENV SKINNYWMS_UWSGI_WORKERS=4

#USER nobody

# UWSGI entrypoint
CMD uwsgi \
--http ${SKINNYWMS_HOST}:${SKINNYWMS_PORT} \
--master \
--process ${SKINNYWMS_UWSGI_WORKERS} \
--mount ${SKINNYWMS_MOUNT}=skinnywms.wmssvr:application \
--manage-script-name \
--uid nobody

# demo application will listen at http://0.0.0.0:5000
EXPOSE 5000/tcp

# start demo
# add option --path <directory with grib files>
# to look for grib files in specific directory
CMD python /app/skinnywms/demo.py --host='0.0.0.0' --port=5000
###CMD python /app/skinnywms/demo.py --host='0.0.0.0' --port=5000

# METADATA
# Build-time metadata as defined at http://label-schema.org
Expand Down
36 changes: 0 additions & 36 deletions Makefile

This file was deleted.

50 changes: 47 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The principle is simple: skinny will browse the directory, or the single file pa
[![Docker Build Status](https://img.shields.io/docker/cloud/build/ecmwf/skinnywms.svg)](https://hub.docker.com/r/ecmwf/skinnywms)
[![Docker Pulls](https://img.shields.io/docker/pulls/ecmwf/skinnywms)](https://hub.docker.com/r/ecmwf/skinnywms)[![PyPI version](https://badge.fury.io/py/skinnywms.svg)](https://badge.fury.io/py/skinnywms) [![Anaconda-Server Badge](https://anaconda.org/conda-forge/skinnywms/badges/version.svg)](https://anaconda.org/conda-forge/skinnywms) [![Anaconda-Server Badge](https://anaconda.org/conda-forge/skinnywms/badges/downloads.svg)](https://anaconda.org/conda-forge/skinnywms)


Features:
---------
SkinnyWMS implements 3 of the WMS endpoints:
Expand Down Expand Up @@ -36,13 +37,41 @@ skinny-wms --path /path/to/mydata
```bash
uwsgi --http localhost:5000 --master --process 20 --mount /=skinnywms.wmssvr:application --env SKINNYWMS_DATA_PATH=/path/to/mydata
```


Run using Docker
----------------

By default the docker image will start the application using uwsgi and will load and display some demo data.

* Run the demo:
```bash
docker run --rm -p 5000:5000 -it ecmwf/skinnywms
```
Now you can try the leaflet demo at http://localhost:5000/

* Run using data on your machine:
```bash
docker run --rm -p 5000:5000 -it \
--volume=/path/to/my/data:/path/inside/the/container \
--env SKINNYWMS_DATA_PATH=/path/inside/the/container \
ecmwf/skinnywms
```
Now you can access the leaflet demo with your data at http://localhost:5000/

* Configure different options by setting environment variables accordingly:
```bash
docker run --rm -p 5000:5000 -i -t ecmwf/skinnywms
```
Now you can try the leaflet demo at http://localhost:5000/
docker run --rm -p 5000:5000 -it \
--volume=/path/to/my/data:/path/inside/the/container \
--env SKINNYWMS_DATA_PATH=/path/inside/the/container \
--env SKINNYWMS_HOST=0.0.0.0 \
--env SKINNYWMS_PORT=5000 \
--env SKINNYWMS_MOUNT=/mymodel/ \
--env SKINNYWMS_UWSGI_WORKERS=4 \
--env SKINNYWMS_ENABLE_DIMENSION_GROUPING=1 \
ecmwf/skinnywms
```
Now you can access the ```GetCapabilities`` document for your data at http://localhost:5000/mymodel/wms?request=GetCapabilities


Installation
Expand All @@ -67,6 +96,13 @@ Limitations:
------------
- SkinnyWMS will perform better on well formatted and documented NetCDF and GRIB.

- grib fields containing corresponding wind components u,v need to be placed together in a single grib file in order to be displayed as vectors/wind barbs in SkinnyWMS. You can combine multiple grib files into a single file using ecCodes ``grib_copy`` (included in the docker image), e.g.:
```bash
grib_copy input_wind_u_component.grb2 input_wind_v_component.grib2 output_wind_u_v_combined.grb2
```

- The time and elevation dimension implementations follow [OGC Met Ocean DWG WMS 1.3 Best Practice for using Web Map Services (WMS) with Time-Dependent or Elevation-Dependent Data](https://external.ogc.org/twiki_public/MetOceanDWG/MetOceanWMSBPOnGoingDrafts). To enable dimension grouping (disabled by default) set the environment variable ``SKINNYWMS_ENABLE_DIMENSION_GROUPING=1``

- development stage: **Alpha**,


Expand Down Expand Up @@ -95,6 +131,14 @@ Magics is available on github https://github.com/ecmwf/magics
Note that *Magics* support for the Windows operating system is experimental.


Start up a local development environment (Docker)
-----------------------------------------

Make sure you have ``Docker`` and ``docker-compose`` installed. Then run:
```bash
docker-compose up
```
This will build a dev image and start up a local flask development server (with automatic reload on code changes) at http://localhost:5000 based on the configuration stored in [docker-compose.yml](./docker-compose.yml) and [.env](./.env) and by default try to load all GRIB and NetCDF data stored in [skinnywms/testdata](./skinnywms/testdata).


Contributing
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.7'

services:
skinnywms:
build:
context: ./
dockerfile: Dockerfile
args:
- PYTHON_IMAGE=python:3.8-slim-buster
- http_proxy
- https_proxy
- no_proxy
volumes:
- '.:/app/skinnywms:ro'
- './skinnywms/testdata:/data:ro'
# override the default command to run flask app without uwgsi
# to make use of automatic reload on code changes for development purposes
command:
- bash
- -c
- 'python /app/skinnywms/demo.py --host=${SKINNYWMS_HOST} --port=${SKINNYWMS_PORT} --path=${SKINNYWMS_DATA_PATH}'
restart: always
ports:
- 5000:5000
env_file:
- ./.env
# environment:
# - SKINNYWMS_DATA_PATH=${SKINNYWMS_DATA_PATH}
# - SKINNYWMS_HOST=${SKINNYWMS_HOST}
# - SKINNYWMS_PORT=${SKINNYWMS_PORT}
# - FLASK_ENV=${FLASK_ENV}
Loading

0 comments on commit 309da2b

Please sign in to comment.