Skip to content

Commit

Permalink
fix precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
vvmruder committed Sep 1, 2024
1 parent adc3250 commit 878a63e
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 76 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.venv
build
dist
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
QSL_DATA_MOUNT=<absolute path where your qgis projects are stored>
QSL_LOG_LEVEL=debug
QSL_REPLICAS=1
QSL_REDIS_URL=redis://redis
23 changes: 23 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: ci

on:
push:
branches:
- master

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Build and push worker
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
target: release
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
*.egg-info/
__pycache__/
src/*.egg-info
.env
build
dist
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:

# Remove unused imports/variables
- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v2.3.1
hooks:
- id: autoflake
args:
Expand Down
44 changes: 37 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
FROM ghcr.io/opengisch/qgis-slim:3.34.10 AS dev
FROM ghcr.io/opengisch/qgis-slim:3.34.10 AS base

# switch to root user for install
USER 0

RUN apt-get update && \
apt-get install -y \
python3-pip \
python3-setuptools

#########################
# DEV
#########################
FROM base AS dev

LABEL org.opengisch.author="Clemens Rudert <[email protected]>"
LABEL org.opengisch.image.title="QGIS-Server-Light"
USER 0

RUN apt-get update -y && \
apt-get install -y \
python3-full \
python3-dev \
make \
build-essential
RUN apt-get install -y \
python3-venv \
make

WORKDIR /opt/qgis-server-light/
ADD requirements.worker.txt .
Expand All @@ -29,3 +39,23 @@ RUN VENV_PATH=${VENV_PATH} make dev
ENTRYPOINT ["/tini", "--", "/opt/qgis-server-light/venv/bin/python3", "-m"]

CMD ["qgis_server_light.worker.redis"]

#########################
# BUILDER (FOR RELEASE)
#########################
FROM base AS builder

WORKDIR /app
COPY ./ .
RUN WITH_WORKER=true python3 setup.py bdist_wheel

#########################
# RELEASE
#########################
FROM base AS release
COPY --from=builder /app/dist/*.whl /tmp
RUN pip3 install /tmp/*.whl

USER 1001

CMD ["redis_worker"]
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ include CHANGES.md
include README.md
include LICENSE.md
include pytest.ini
include requirements.*
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $(QGIS_VENV_PATH):
echo "/usr/share/qgis/python" > $@

$(PIP_REQUIREMENTS): $(VENV_REQUIREMENTS) requirements.interface.txt requirements.worker.txt requirements.exporter.txt $(QGIS_VENV_PATH)
$(VENV_BIN)/$(PIP_COMMAND) install --upgrade pip
$(VENV_BIN)/$(PIP_COMMAND) install --upgrade pip wheel
$(VENV_BIN)/$(PIP_COMMAND) install -r requirements.interface.txt -r requirements.worker.txt -r requirements.exporter.txt
touch $@

Expand All @@ -55,6 +55,7 @@ install: $(PIP_REQUIREMENTS)

.PHONY: build
build: $(BUILD_DEPS)
$(VENV_BIN)/python setup.py bdist_wheel

.PHONY: clean
clean:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ the recommended way of running this stack is Docker (docker need to be installed

First you need to build the image:
```shell
docker build -t qgis-server-light:3.34.8-dev --target dev .
docker build -t opengisch/qgis-server-light:dev --target dev .
```

Then run:
```shell
docker run --rm -e REDIS_URL=redis://localhost:1234 -e LOG_LEVEL=debug -v $(pwd):/app --net host qgis-server-light:3.34.8-dev
docker run --rm -e REDIS_URL=redis://localhost:1234 -e LOG_LEVEL=debug -v $(pwd):/app --net host opengisch/qgis-server-light:dev
```

Congratulations... Your QGIS-Server-Light is running and waits for jobs in the redis queue.
Expand All @@ -102,7 +102,7 @@ If you have issues with matching QGIS version on your system and the one used by
you should prefer the docker way with the source code mounted to the running container.

```shell
docker run --rm -e REDIS_URL=redis://localhost:1234 -e LOG_LEVEL=debug -v $(pwd):/app --net host qgis-server-light:3.34.8-dev
docker run --rm -e REDIS_URL=redis://localhost:1234 -e LOG_LEVEL=debug -v $(pwd):/app --net host opengisch/qgis-server-light:dev
```

That way the current changes you make are transparently available in the container.
Expand Down
14 changes: 9 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
services:
qgis-server-light:
image: qgis-server-light:3.34.8-dev
image: opengisch/qgis-server-light:dev
env_file:
- .env
build:
context: .
dockerfile: ./Dockerfile
target: dev
restart: unless-stopped
environment:
- "REDIS_URL=redis://redis"
- "LOG_LEVEL=debug"
- "QSL_DATA_ROOT=/io/data"
volumes:
- ../data/project_store/:/io/themes:ro
- ./:/app
- "../data/project_store/:/io/themes:ro"
- "./:/app"
- "${QSL_DATA_MOUNT}:/io/data"
deploy:
replicas: ${QSL_REPLICAS}
redis:
image: redis:7.4.0
ports:
Expand Down
95 changes: 53 additions & 42 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,73 @@
import os
import re

from setuptools import setup, find_packages
from setuptools import setup

here = os.path.abspath(os.path.dirname(__name__))
with open(os.path.join(here, 'README.md')) as f:
with open(os.path.join(here, "README.md")) as f:
README = f.read()
with open(os.path.join(here, 'CHANGES.md')) as f:
with open(os.path.join(here, "CHANGES.md")) as f:
CHANGES = f.read()

with open(os.path.join(here, 'requirements.interface.txt')) as f:
re_ = re.compile(r'(.+)==')
recommend = f.read().splitlines()
requires = [re_.match(r).group(1) for r in recommend]
with open(os.path.join(here, "requirements.interface.txt")) as f:
install_requires = f.read().splitlines()

tests_require = [
'pytest', # includes virtualenv
'pytest-cov'
]
tests_require = ["pytest", "pytest-cov"] # includes virtualenv
worker_files = {}
worker_modules = []
worker_packages = []
worker_scripts = []
if os.environ.get("WITH_WORKER", False):
with open(os.path.join(here, "requirements.worker.txt")) as f:
install_requires = install_requires + f.read().splitlines()

worker_files = {"qgis_server_light.worker": ["*.py"]}
worker_modules = [
"qgis_server_light/worker/engine",
"qgis_server_light/worker/image_utils",
"qgis_server_light/worker/qgis",
"qgis_server_light/worker/redis",
"qgis_server_light/worker/runner",
]
worker_packages = ["qgis_server_light.worker"]
worker_scripts = ["redis_worker=qgis_server_light.worker.redis:main"]

package_data = {"qgis_server_light.interface": ["*.py"]}
package_data.update(worker_files)

setup(
name='qgis_server_light',
version='v0.0.1',
description='qgis renderer as a python process',
long_description=README + '\n\n' + CHANGES,
name="qgis_server_light",
version="v0.0.1",
description="qgis renderer as a python process",
long_description=README + "\n\n" + CHANGES,
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Framework :: Pyramid",
"Programming Language :: Python :: 3.10",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Topic :: Internet :: WWW/HTTP :: ASGI :: Application",
"Typing :: Typed",
],
author='Clemens Rudert (OPENGIS.ch)',
author_email='[email protected]',
url='https://github.com/opengisch/qgis-server-light',
keywords=['web worker qgis qgis-server processing'],
packages=['qgis_server_light.interface'],
package_dir={'': 'src'},
package_data={
"qgis_server_light.interface": ["*.py"]
},
author="Clemens Rudert (OPENGIS.ch)",
author_email="[email protected]",
url="https://github.com/opengisch/qgis-server-light",
keywords=["web worker qgis qgis-server processing"],
packages=["qgis_server_light.interface"] + worker_packages,
package_dir={"": "src"},
package_data=package_data,
py_modules=[
'qgis_server_light/interface/job',
'qgis_server_light/interface/dispatcher',
'qgis_server_light/interface/qgis'

],
"qgis_server_light/interface/job",
"qgis_server_light/interface/dispatcher",
"qgis_server_light/interface/qgis",
]
+ worker_modules,
include_package_data=True,
zip_safe=False,
project_urls={
'Documentation': 'https://github.com/opengisch/qgis-server-light',
'Changelog': 'https://github.com/opengisch/qgis-server-light/blob/master/CHANGES.md',
'Issue Tracker': 'https://github.com/opengisch/qgis-server-light/issues',
},
extras_require={
'recommend': recommend,
'no-version': requires,
'testing': tests_require,
"Documentation": "https://github.com/opengisch/qgis-server-light",
"Changelog": "https://github.com/opengisch/qgis-server-light/blob/master/CHANGES.md",
"Issue Tracker": "https://github.com/opengisch/qgis-server-light/issues",
},
entry_points={
}
install_requires=install_requires,
entry_points={"console_scripts": [] + worker_scripts},
)
Loading

0 comments on commit 878a63e

Please sign in to comment.