Skip to content

Commit

Permalink
Add update handling (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
scmmmh authored Aug 24, 2023
1 parent 324e9c5 commit c1a3ff2
Show file tree
Hide file tree
Showing 17 changed files with 3,669 additions and 4,499 deletions.
92 changes: 46 additions & 46 deletions .github/workflows/deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,55 @@ name: Docker Deployment
on:
push:
tags:
- 'v*'
- "v*"

jobs:
build-and-deploy:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/v}
- name: Setup Path
run: |
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
echo "PIPX_BIN_DIR=$HOME/.local/bin" >> $GITHUB_ENV
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install Base Dependencies
run: |
sudo apt-get update
sudo apt-get install python3-venv pipx
pipx install poetry
- name: Build Application
run: |
poetry build
cp dist/*.whl docker/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: scmmmh
password: ${{ secrets.DOCKERACCESSTOKEN }}

- name: Build and Push Image
uses: docker/build-push-action@v4
with:
context: docker
push: true
tags: scmmmh/museum-map:${{ steps.branch_name.outputs.SOURCE_TAG }}
- uses: actions/checkout@v3

- name: Branch name
id: branch_name
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/v}
- name: Setup Path
run: |
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
echo "PIPX_BIN_DIR=$HOME/.local/bin" >> $GITHUB_ENV
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Base Dependencies
run: |
sudo apt-get update
sudo apt-get install python3-venv pipx
pipx install hatch
- name: Build Application
run: |
hatch build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: scmmmh
password: ${{ secrets.DOCKERACCESSTOKEN }}

- name: Build and Push Image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile
push: true
tags: scmmmh/museum-map:${{ steps.branch_name.outputs.SOURCE_TAG }}
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Path
run: |
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
echo "PIPX_BIN_DIR=$HOME/.local/bin" >> $GITHUB_ENV
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Base Dependencies
run: |
sudo apt-get update
sudo apt-get install python3-venv pipx
pipx install hatch
- name: Build Application
run: |
hatch build
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-yaml
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
54 changes: 22 additions & 32 deletions CHANGES.rst → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,74 @@
Changelog
=========
# Changelog

0.8.2
-----
## Dev

* **New**: Add an indicator when a frontend reload is required
* **Chore**: Update all dependencies
* **Chore**: Switch to using hatch

## 0.8.2

* **Bugfix**: Fix security issues in dependencies

0.8.1
-----
## 0.8.1

* **Bugfix**: Fixed a security issue in Tornado

0.8.0
-----
## 0.8.0

* **Update**: Updated the search library
* **Bugfix**: Fixed an issue with navigating to the lobby after searching
* **Bugfix**: Fixed a layout issue with the heading

0.7.3
-----
## 0.7.3

* **New**: Implemented search
* **Bugfix**: Fixed an a11y issue in the floor display

0.7.1
-----
## 0.7.1

* **Bugfix**: Fixed an issue with the floor previews positioning

0.7.0
-----
## 0.7.0

* **Update**: Added floor previews
* **Update**: Improved the floor browsing UI
* **Bugfix**: Fixed an issue with the footer layout

0.6.0
-----
## 0.6.0

* **Update**: Rewrite of the floor browsing UI

0.2.6
-----
## 0.2.6

* **Update**: Performance improvements

0.2.5
-----
## 0.2.5

* **Bugfix**: Fix dependency versions

0.2.4
-----
## 0.2.4

* **Bugfix**: Fix an issue with the release preparation

0.2.3
-----
## 0.2.3

* **Update**: Performance improvements

0.2.2
-----
## 0.2.2

* **Update**: Work from python 3.9
* **Bugfix**: Fixed issues required for asyncpg

0.2.1
-----
## 0.2.1

* **Bugfix**: Deploy the production code

0.2.0
-----
## 0.2.0

* **New**: Floor navigation
* **Update**: Improved lobby

0.1.0
-----
## 0.1.0

* **New**: Initial version
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9
FROM python:3.11

ARG MM_USER="museum-map"
ARG MM_UID="10000"
Expand All @@ -14,11 +14,11 @@ RUN apt-get update && \
apt-get install -y tini

# Copy the application file
COPY museum_map-0.8.2-py3-none-any.whl /tmp/
COPY dist/*.whl /tmp/

# Install the application
RUN python -m pip install /tmp/museum_map-0.8.2-py3-none-any.whl[postgres]
COPY start_museum_map.sh /usr/bin/
RUN python -m pip install /tmp/*.whl
COPY docker/start_museum_map.sh /usr/bin/
RUN chmod a+x /usr/bin/start_museum_map.sh && \
mkdir /var/lib/museum-map && \
mkdir /etc/museum-map && \
Expand Down
28 changes: 22 additions & 6 deletions museum_map/cli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

from importlib import resources
from sqlalchemy.ext.asyncio import create_async_engine
from tornado.ioloop import IOLoop
from tornado.ioloop import IOLoop
from tornado.web import Application, StaticFileHandler

from ..models import create_engine
from ..server.handlers import (APICollectionHandler, APIConfigHandler, APIItemHandler, APIPickHandler, FrontendHandler,
APISearchHandler, create_inject_item_html)
from ..server.handlers import (
APICollectionHandler,
APIConfigHandler,
APIItemHandler,
APIPickHandler,
FrontendHandler,
APIStatusHandler,
APISearchHandler,
create_inject_item_html,
)


@click.command()
Expand All @@ -16,17 +24,25 @@ def run(ctx):
config = ctx.obj['config']
app = Application(
[
('/api', APIStatusHandler),
('/api/picks/([a-z\-]+)', APIPickHandler),
('/api/config/all', APIConfigHandler, {'config': config}),
('/api/search', APISearchHandler),
('/api/([a-z\-]+)', APICollectionHandler),
('/api/([a-z\-]+)/([0-9]+)', APIItemHandler),
('/images/(.*)', StaticFileHandler, {'path': config['images']['basepath']}),
('/(.*)', FrontendHandler, {'base': resources.files('museum_map') / 'server' / 'frontend' / 'public',
'html_injectors': {r'room/([0-9]+)/([0-9]+)': create_inject_item_html(config)}}),
(
'/(.*)',
FrontendHandler,
{
'base': resources.files('museum_map') / 'server' / 'frontend' / 'public',
'html_injectors': {r'room/([0-9]+)/([0-9]+)': create_inject_item_html(config)},
},
),
],
autoreload=True,
config=config)
config=config,
)
app.listen(config['server']['port'], address=config['server']['host'])
IOLoop.current().start()

Expand Down
Loading

0 comments on commit c1a3ff2

Please sign in to comment.